-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add more textbox opcodes, document additional potential opcodes
- Loading branch information
Showing
20 changed files
with
370 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/G2DataGUI.Common/Data/Maps/MapDialogueOpcodes/CameraMoveOpcode.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/G2DataGUI.Common/Data/Maps/MapDialogueOpcodes/CharacterPortaitOpcode.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/G2DataGUI.Common/Data/Maps/MapDialogueOpcodes/CreateOptionsTextBoxOpcode.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using G2DataGUI.Common.Data.Maps.MapDialogueOpcode; | ||
using G2DataGUI.Common.Extensions; | ||
using G2DataGUI.IO.Streams; | ||
|
||
namespace G2DataGUI.Common.Data.Maps.MapDialogueOpcodes; | ||
|
||
/// <summary> | ||
/// Creates a textbox in the top-left of the screen | ||
/// that displays a list of options for the palyer to choose from. | ||
/// </summary> | ||
public class CreateOptionsTextBoxOpcode : ITextBoxOpcode, IMapDialogueOpcode | ||
{ | ||
public DialogueOpcode Opcode { get; set; } = DialogueOpcode.TextBox; | ||
public TextBoxOption Option { get; set; } = TextBoxOption.CreateOptionsTextBox; | ||
public byte TextBoxLength { get; set; } | ||
public byte TextBoxHeight { get; set; } | ||
public IList<IMapDialogueOpcode> NestedOpcodes { get; set; } = new List<IMapDialogueOpcode>(); | ||
|
||
public static IMapDialogueOpcode ReadOpcode(Stream reader) | ||
{ | ||
CreateOptionsTextBoxOpcode opcode = new() | ||
{ | ||
TextBoxLength = reader.ReadRawByte(), | ||
TextBoxHeight = reader.ReadRawByte(), | ||
}; | ||
|
||
do | ||
{ | ||
byte data = reader.ReadRawByte(); | ||
if (data.EnumExists<DialogueOpcode>()) | ||
{ | ||
switch (data.ToEnum<DialogueOpcode>()) | ||
{ | ||
case DialogueOpcode.ScriptCall: | ||
opcode.NestedOpcodes.Add(ScriptCallOpcode.ReadOpcode(reader)); | ||
break; | ||
case DialogueOpcode.CameraMove: | ||
opcode.NestedOpcodes.Add(CameraMoveOpcode.ReadOpcode(reader)); | ||
break; | ||
case DialogueOpcode.ItemAquire: | ||
opcode.NestedOpcodes.Add(ItemAcquireOpcode.ReadOpcode(reader)); | ||
break; | ||
case DialogueOpcode.CharacterPortait: | ||
opcode.NestedOpcodes.Add(CharacterPortaitOpcode.ReadOpcode(reader)); | ||
break; | ||
case DialogueOpcode.NextPage: | ||
opcode.NestedOpcodes.Add(NextPageOpcode.ReadOpcode(reader)); | ||
break; | ||
case DialogueOpcode.Pause: | ||
opcode.NestedOpcodes.Add(PauseOpcode.ReadOpcode(reader)); | ||
break; | ||
case DialogueOpcode.NextLine: | ||
opcode.NestedOpcodes.Add(NextLineOpcode.ReadOpcode(reader)); | ||
break; | ||
// textbox removal should be the only thing that returns the textbox | ||
// should verify it isn't a textbox within a textbox(is that even possible?) | ||
case DialogueOpcode.TextBox: | ||
opcode.NestedOpcodes.Add(ITextBoxOpcode.ReadOpcode(reader)); | ||
return opcode; | ||
} | ||
} | ||
else | ||
{ | ||
reader.Seek(-1, SeekOrigin.Current); | ||
opcode.NestedOpcodes.Add(TextOpcode.ReadOpcode(reader)); | ||
} | ||
} while (true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
src/G2DataGUI.Common/Data/Maps/MapDialogueOpcodes/CreateSubTextBoxOpcode.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using G2DataGUI.Common.Extensions; | ||
using G2DataGUI.IO.Streams; | ||
|
||
namespace G2DataGUI.Common.Data.Maps.MapDialogueOpcode; | ||
|
||
/// <summary> | ||
/// Defines a sub textbox that appears during dialogue. | ||
/// Sub textboxes appear overlapping the primary textbox | ||
/// in the top-right of the primary textbox. | ||
/// </summary> | ||
internal class CreateSubTextBoxOpcode : ITextBoxOpcode, IMapDialogueOpcode | ||
{ | ||
public DialogueOpcode Opcode { get; set; } = DialogueOpcode.TextBox; | ||
public TextBoxOption Option { get; set; } = TextBoxOption.CreateSubTextBox; | ||
public byte Unknown1 { get; set; } | ||
public byte TextBoxHeight { get; set; } | ||
public IList<IMapDialogueOpcode> NestedOpcodes { get; set; } = new List<IMapDialogueOpcode>(); | ||
|
||
public static IMapDialogueOpcode ReadOpcode(Stream reader) | ||
{ | ||
CreateSubTextBoxOpcode opcode = new() | ||
{ | ||
Unknown1 = reader.ReadRawByte(), | ||
TextBoxHeight = reader.ReadRawByte(), | ||
}; | ||
|
||
do | ||
{ | ||
byte data = reader.ReadRawByte(); | ||
if (data.EnumExists<DialogueOpcode>()) | ||
{ | ||
switch (data.ToEnum<DialogueOpcode>()) | ||
{ | ||
case DialogueOpcode.ScriptCall: | ||
opcode.NestedOpcodes.Add(ScriptCallOpcode.ReadOpcode(reader)); | ||
break; | ||
case DialogueOpcode.CameraMove: | ||
opcode.NestedOpcodes.Add(CameraMoveOpcode.ReadOpcode(reader)); | ||
break; | ||
case DialogueOpcode.ItemAquire: | ||
opcode.NestedOpcodes.Add(ItemAcquireOpcode.ReadOpcode(reader)); | ||
break; | ||
case DialogueOpcode.CharacterPortait: | ||
opcode.NestedOpcodes.Add(CharacterPortaitOpcode.ReadOpcode(reader)); | ||
break; | ||
case DialogueOpcode.NextPage: | ||
opcode.NestedOpcodes.Add(NextPageOpcode.ReadOpcode(reader)); | ||
break; | ||
case DialogueOpcode.Pause: | ||
opcode.NestedOpcodes.Add(PauseOpcode.ReadOpcode(reader)); | ||
break; | ||
case DialogueOpcode.NextLine: | ||
opcode.NestedOpcodes.Add(NextLineOpcode.ReadOpcode(reader)); | ||
break; | ||
// textbox removal should be the only thing that returns the textbox | ||
// should verify it isn't a textbox within a textbox(is that even possible?) | ||
case DialogueOpcode.TextBox: | ||
opcode.NestedOpcodes.Add(ITextBoxOpcode.ReadOpcode(reader)); | ||
return opcode; | ||
} | ||
} | ||
else | ||
{ | ||
reader.Seek(-1, SeekOrigin.Current); | ||
opcode.NestedOpcodes.Add(TextOpcode.ReadOpcode(reader)); | ||
} | ||
} while (true); | ||
} | ||
} |
Oops, something went wrong.