Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bugs introduced in 580 #1240

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions EditorController/EditorController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,13 @@ public ValidationResult AddInheritedTypeToElement(string elementName, string typ

return new ValidationResult { Valid = true };
}

public ValidationResult AddFieldToElement(string elementName, string field, bool value)
{
Element element = m_worldModel.Elements.Get(elementName);
element.Fields.Set(field,value);
return new ValidationResult { Valid = true };
}

public void RemoveInheritedTypeFromElement(string elementName, string typeName, bool useTransaction)
{
Expand Down Expand Up @@ -1323,14 +1330,14 @@ public bool DoesElementInheritType(string elementName, string typeName)
public void CreateNewObject(string name, string parent, string alias)
{
m_worldModel.UndoLogger.StartTransaction(string.Format("Create object '{0}'", name));
CreateNewObject(name, parent, "editor_object", alias);
CreateNewObject(name, parent, "editor_object", alias, false);
m_worldModel.UndoLogger.EndTransaction();
}

public void CreateNewRoom(string name, string parent, string alias)
{
m_worldModel.UndoLogger.StartTransaction(string.Format("Create room '{0}'", name));
CreateNewObject(name, parent, "editor_room", alias);
CreateNewObject(name, parent, "editor_room", alias, true);
m_worldModel.UndoLogger.EndTransaction();
}

Expand Down Expand Up @@ -1419,7 +1426,7 @@ private string CreateNewAnonymousObject(string parent, string typeName, ObjectTy
return newObject.Name;
}

private void CreateNewObject(string name, string parent, string editorType, string alias)
private void CreateNewObject(string name, string parent, string editorType, string alias, Boolean isRoom)
{
Element newObject = m_worldModel.GetElementFactory(ElementType.Object).Create(name);
if (parent != null)
Expand All @@ -1430,6 +1437,9 @@ private void CreateNewObject(string name, string parent, string editorType, stri
{
newObject.Fields[FieldDefinitions.Alias] = alias;
}

newObject.Fields[FieldDefinitions.IsRoom] = isRoom;

if (m_worldModel.Elements.ContainsKey(ElementType.ObjectType, editorType))
{
newObject.Fields.AddTypeUndoable(m_worldModel.Elements.Get(ElementType.ObjectType, editorType));
Expand Down
18 changes: 18 additions & 0 deletions EditorControls/DropDownTypesControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ public void Save()

m_helper.Controller.StartTransaction(String.Format("Change type from '{0}' to '{1}'", m_dropDownValues[m_currentType], m_dropDownValues[selectedType]));

if (selectedType == k_noType)
{
if (m_currentType == "editor_object" || m_currentType == "editor_room")
{
m_helper.Controller.AddFieldToElement(m_data.Name, "isroom", true);
}
}

if (m_currentType != k_noType)
{
m_helper.Controller.RemoveInheritedTypeFromElement(m_data.Name, m_currentType, false);
Expand All @@ -124,6 +132,16 @@ public void Save()
if (selectedType != k_noType)
{
m_helper.Controller.AddInheritedTypeToElement(m_data.Name, selectedType, false);
if (selectedType == "editor_room")
{
m_helper.Controller.AddFieldToElement(m_data.Name, "isroom", true);
//m_helper.Controller.AddFieldToElement(m_data.Name, "isroommanual", false);
}
else if (selectedType == "editor_object")
{
m_helper.Controller.AddFieldToElement(m_data.Name, "isroom", false);
//m_helper.Controller.AddFieldToElement(m_data.Name, "isroommanual", false);
}
}

m_helper.Controller.EndTransaction();
Expand Down
38 changes: 30 additions & 8 deletions Player/PlayerHTML.vb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ Public Class PlayerHTML
Case "RestartGame"
RestartGame(args)
Case "SaveTranscript"
SaveTranscript(args)
WriteToTranscript(args)
Case "WriteToTranscript"
WriteToTranscript(args)
Case "WriteToLog"
WriteToLog(args)
End Select
Expand All @@ -114,8 +116,11 @@ Public Class PlayerHTML
Dim logPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\Quest Logs"
Dim gameName = Split(CurrentGame.Filename, "\")(Split(CurrentGame.Filename, "\").Length - 1)
gameName = gameName.Replace(".aslx", "")
If Not System.IO.Directory.Exists(logPath) = True Then
If Not System.IO.Directory.Exists(logPath) = True Or data.Contains("@@@OVERWRITEFILE@@@") Then
System.IO.Directory.CreateDirectory(logPath)
If data.Contains("@@@OVERWRITEFILE@@@") Then
data = Replace(data, "@@@OVERWRITEFILE@@@", "")
End If
End If
If Not System.IO.File.Exists(logPath + "\" + gameName + "-log.txt") = True Then
Dim file As System.IO.FileStream
Expand All @@ -124,19 +129,36 @@ Public Class PlayerHTML
End If
My.Computer.FileSystem.WriteAllText(logPath + "\" + gameName + "-log.txt", data + Environment.NewLine, True)
End Sub
Private Sub SaveTranscript(data As String)
Dim mgameName = Split(CurrentGame.Filename, "\")(Split(CurrentGame.Filename, "\").Length - 1)
mgameName = mgameName.Replace(".aslx", "")
Private Sub WriteToTranscript(data As String)
Dim mgameName = ""
Dim scriptname = "DEFAULT_"
' In playercore.js: WriteToTranscript (transcriptName + "___SCRIPTDATA___" + text)
' If WriteToTranscript(text) is used, this will ignore the transcript name and use the game's file name.
If data.Contains("___SCRIPTDATA___") Then
scriptname = Split(data, "___SCRIPTDATA___")(0)
End If
If scriptname = "DEFAULT_" Then
mgameName = Split(CurrentGame.Filename, "\")(Split(CurrentGame.Filename, "\").Length - 1)
mgameName = mgameName.Replace(".aslx", "")
Else
mgameName = scriptname
End If
Dim transcriptPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\Quest Transcripts"
If Not System.IO.Directory.Exists(transcriptPath) = True Then
System.IO.Directory.CreateDirectory(transcriptPath)
End If
If Not System.IO.File.Exists(transcriptPath + "\" + mgameName + "-transcript.html") = True Then
If Not System.IO.File.Exists(transcriptPath + "\" + mgameName + "-transcript.txt") = True Or data.Contains("@@@OVERWRITEFILE@@@") Then
Dim file As System.IO.FileStream
file = System.IO.File.Create(transcriptPath + "\" + mgameName + "-transcript.html")
file = System.IO.File.Create(transcriptPath + "\" + mgameName + "-transcript.txt")
file.Close()
If data.Contains("@@@OVERWRITEFILE@@@") Then
data = Replace(data, "@@@OVERWRITEFILE@@@", "")
End If
End If
If data.Contains("___SCRIPTDATA___") Then
data = Split(data, "___SCRIPTDATA___")(1)
End If
My.Computer.FileSystem.WriteAllText(transcriptPath + "\" + mgameName + "-transcript.html", data, True)
My.Computer.FileSystem.WriteAllText(transcriptPath + "\" + mgameName + "-transcript.txt", Replace(data, "@@@NEW_LINE@@@", Environment.NewLine), True)

End Sub
Private Sub RestartGame(data As String)
Expand Down
16 changes: 11 additions & 5 deletions Player/desktopplayer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var webPlayer = false;
var canSendCommand = true;
var platform = "desktop";

(async function () {
await CefSharp.BindObjectAsync("questCefInterop");
Expand All @@ -25,16 +26,21 @@ function RestartGame() {
UIEvent("RestartGame", "");
}

// SaveTranscript added by KV to write/append to GAMENAME-transcript.html in Documents\Quest Transcripts
// SaveTranscript "renamed"/replaced by WriteToTranscript
function SaveTranscript(data) {
data = data + "<style>*{color:black !important;background:white !important;text-align:left !important}</style>";
if (!webPlayer && transcriptString != '') { UIEvent("SaveTranscript", data); }
transcriptString += data;
WriteToTranscript(data);
}

// WriteToTranscript added by KV to write/append to GAMENAME-transcript.txt in Documents\Quest Transcripts
function WriteToTranscript(data) {
if (data != '' && typeof (data) == 'string') {
UIEvent("WriteToTranscript", data);
}
}

// Added by KV to write/append to GAMENAME-log.txt in Documents\Quest Logs
function WriteToLog(data) {
if (!webPlayer && data != '' && typeof (data) == 'string') {
if (data != '' && typeof (data) == 'string') {
UIEvent("WriteToLog", getTimeAndDateForLog() + " " + data);
}
}
Expand Down
Loading