Skip to content

Commit

Permalink
error messages + medallion fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jxjacob committed Jul 25, 2023
1 parent b45fa8d commit 16dd21d
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 32 deletions.
56 changes: 35 additions & 21 deletions GSTHD/AttachToEmulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ public static Tuple<Process, uint> attachToProject64(Form1 baseForm, bool doOffs
{
target = Process.GetProcessesByName("project64")[0];
}
catch (Exception)
catch (Exception e)
{
MessageBox.Show(e.Message + "\nCould not find process \"project64\" on your machine.", "GSTHD", MessageBoxButtons.OK, MessageBoxIcon.Error);
return null;
}

Expand Down Expand Up @@ -92,24 +93,29 @@ public static Tuple<Process, uint> attachToProject64(Form1 baseForm, bool doOffs
return Tuple.Create(target, romAddrStart);
}

for (int i = 0; i < 4; i++)
//for (int i = 0; i < 4; i++)
//{
// switch (i)
// {

for (uint potOff = 0xDFD00000; potOff < 0xE01FFFFF; potOff += 16)
{
switch (i)
{
case 0:
romAddrStart = 0xDFE40000;
break;
case 1:
romAddrStart = 0xDFE70000;
break;
case 2:
romAddrStart = 0xDFFB0000;
break;
default:
Debug.WriteLine("wasnt those 3 addresses");
return null;

}
//case 0:
// romAddrStart = 0xDFE40000;
// break;
//case 1:
// romAddrStart = 0xDFE70000;
// break;
//case 2:
// romAddrStart = 0xDFFB0000;
// break;
//default:
// MessageBox.Show("Could not find the correct PJ64 offset\nPlease find JXJacob and alert him about this immediately so he can implement a fix to an issue he predicted would eventually happen.", "GSTHD", MessageBoxButtons.OK, MessageBoxIcon.Error);
// return null;

//}
romAddrStart= potOff;

int gamecheck = 0;
try
Expand Down Expand Up @@ -138,15 +144,18 @@ public static Tuple<Process, uint> attachToProject64(Form1 baseForm, bool doOffs
{
Debug.WriteLine("yeah bud shits fucked");
MessageBox.Show(e.Message, "GSTHD", MessageBoxButtons.OK, MessageBoxIcon.Error);
return null;
}

//MessageBox.Show(gamecheck.ToString("X"), "GSTHD", MessageBoxButtons.OK, MessageBoxIcon.Error);
//return null;
if (gamecheck == gameInfo.Item3)
{
Debug.WriteLine("verifyably pj64");
return Tuple.Create(target, romAddrStart);
}

}
//MessageBox.Show("Could not find the correct PJ64 offset\nJXJacob hasn't figured out how to solve this one so you might be out of luck.", "GSTHD", MessageBoxButtons.OK, MessageBoxIcon.Error);
return null;
}

Expand All @@ -159,8 +168,9 @@ public static Tuple<Process, uint> attachToBizhawk(Form1 baseForm)
{
target = Process.GetProcessesByName("emuhawk")[0];
}
catch (Exception)
catch (Exception e)
{
MessageBox.Show(e.Message + "\nCould not find process \"emuhawk\" on your machine.", "GSTHD", MessageBoxButtons.OK, MessageBoxIcon.Error);
return null;
}
Debug.WriteLine("found hawk");
Expand Down Expand Up @@ -238,6 +248,7 @@ public static Tuple<Process, uint> attachToBizhawk(Form1 baseForm)
{
Debug.WriteLine("yeah bud shits fucked");
MessageBox.Show(e.Message, "GSTHD", MessageBoxButtons.OK, MessageBoxIcon.Error);
return null;
}


Expand All @@ -253,7 +264,7 @@ public static Tuple<Process, uint> attachToBizhawk(Form1 baseForm)




//MessageBox.Show("Could not find the correct Bizhawk-DK64 offset\nJXJacob hasn't figured out how to solve this one so you might be out of luck.", "GSTHD", MessageBoxButtons.OK, MessageBoxIcon.Error);
return null;
}

Expand All @@ -265,8 +276,9 @@ public static Tuple<Process, ulong> attachToRMG(Form1 baseForm)
{
target = Process.GetProcessesByName("rmg")[0];
}
catch (Exception)
catch (Exception e)
{
MessageBox.Show(e.Message + "\nCould not find process \"rmg\" on your machine.", "GSTHD", MessageBoxButtons.OK, MessageBoxIcon.Error);
return null;
}
Debug.WriteLine("trans rights");
Expand All @@ -286,6 +298,7 @@ public static Tuple<Process, ulong> attachToRMG(Form1 baseForm)

if (addressDLL == 0)
{
MessageBox.Show("Could not find mupen64plus loaded within RMG.\nPlease reinstall RMG or reset it to its default settings.", "GSTHD", MessageBoxButtons.OK, MessageBoxIcon.Error);
return null;
}
Debug.WriteLine("found dll at 0x" + addressDLL.ToString("X"));
Expand Down Expand Up @@ -339,6 +352,7 @@ public static Tuple<Process, ulong> attachToRMG(Form1 baseForm)

}

//MessageBox.Show("Could not find the correct RMG offset\nJXJacob hasn't figured out how to solve this one so you might be out of luck.", "GSTHD", MessageBoxButtons.OK, MessageBoxIcon.Error);
return null;
}
}
Expand Down
3 changes: 3 additions & 0 deletions GSTHD/DraggableAutocheckElementBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public DraggableAutocheckElementBehaviour(DraggableAutocheckElement<T> element,
: base(element, settings)
{
Element = element;
Settings = settings;

LastState = Element.GetState();
}

public void Mouse_Move_WithAutocheck(object sender, MouseEventArgs e)
Expand Down
6 changes: 3 additions & 3 deletions GSTHD/Form1_MenuBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ public void menuBar_ConnectToEmulator(object sender, EventArgs e)
}
else
{
MessageBox.Show("Could not connect to PJ64", "GSTHD", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show("Could not connect to PJ64\nMake sure the game you want to track is loaded in the emulator before connecting.", "GSTHD", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
break;
case "Bizhawk":
Expand All @@ -645,7 +645,7 @@ public void menuBar_ConnectToEmulator(object sender, EventArgs e)
}
else
{
MessageBox.Show("Could not connect to Bizhawk-DK64", "GSTHD", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show("Could not connect to Bizhawk-DK64\nMake sure the game you want to track is loaded in the emulator before connecting.", "GSTHD", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
break;
case "RMG":
Expand All @@ -660,7 +660,7 @@ public void menuBar_ConnectToEmulator(object sender, EventArgs e)
}
else
{
MessageBox.Show("Could not connect to RMG", "GSTHD", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show("Could not connect to RMG\nMake sure the game you want to track is loaded in the emulator before connecting.", "GSTHD", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
break;
default:
Expand Down
22 changes: 14 additions & 8 deletions GSTHD/Medallion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ public struct MedallionState
public override string ToString() => $"{DungeonIndex},{ImageIndex}";
}

public class Medallion : PictureBox, UpdatableFromSettings, ProgressibleElement<MedallionState>, DraggableElement<MedallionState>
public class Medallion : PictureBox, UpdatableFromSettings, ProgressibleElement<MedallionState>, DraggableAutocheckElement<MedallionState>
{
private readonly Settings Settings;
private readonly ProgressibleElementBehaviour<MedallionState> ProgressBehaviour;
private readonly DraggableElementBehaviour<MedallionState> DragBehaviour;
private readonly DraggableAutocheckElementBehaviour<MedallionState> DragBehaviour;

private string[] ImageNames;
private string[] DungeonNames;
Expand Down Expand Up @@ -78,7 +78,7 @@ public Medallion(ObjectPointMedallion data, Settings settings, bool isBroadcast
}

ProgressBehaviour = new ProgressibleElementBehaviour<MedallionState>(this, Settings);
DragBehaviour = new DraggableElementBehaviour<MedallionState>(this, Settings);
DragBehaviour = new DraggableAutocheckElementBehaviour<MedallionState>(this, Settings);

Location = new Point(data.X, data.Y);
TabStop = false;
Expand All @@ -88,7 +88,8 @@ public Medallion(ObjectPointMedallion data, Settings settings, bool isBroadcast
MouseUp += DragBehaviour.Mouse_ClickUp;
MouseDown += ProgressBehaviour.Mouse_ClickDown;
MouseDown += DragBehaviour.Mouse_ClickDown;
MouseMove += DragBehaviour.Mouse_Move;
MouseMove += DragBehaviour.Mouse_Move_WithAutocheck;
MouseWheel += DragBehaviour.Mouse_Wheel;
}


Expand All @@ -108,7 +109,8 @@ public Medallion(ObjectPointMedallion data, Settings settings, bool isBroadcast
SelectedDungeon.MouseUp += DragBehaviour.Mouse_ClickUp;
SelectedDungeon.MouseDown += ProgressBehaviour.Mouse_ClickDown;
SelectedDungeon.MouseDown += DragBehaviour.Mouse_ClickDown;
SelectedDungeon.MouseMove += DragBehaviour.Mouse_Move;
SelectedDungeon.MouseMove += DragBehaviour.Mouse_Move_WithAutocheck;
SelectedDungeon.MouseWheel += DragBehaviour.Mouse_Wheel;

UpdateFromSettings();
}
Expand Down Expand Up @@ -149,6 +151,7 @@ private void Mouse_Wheel(object sender, MouseEventArgs e)
else if (DungeonIndex >= DungeonNames.Length) DungeonIndex = DungeonNames.Length - 1;
SelectedDungeon.Text = DungeonNames[DungeonIndex];
SetSelectedDungeonLocation();
DragBehaviour.SaveChanges();
if (isBroadcastable && Application.OpenForms["GSTHD_DK64 Broadcast View"] != null)
{
((Medallion)Application.OpenForms["GSTHD_DK64 Broadcast View"].Controls.Find(this.Name, true)[0]).SelectedDungeon.Text = DungeonNames[DungeonIndex];
Expand All @@ -166,6 +169,7 @@ private void Mouse_Wheel_WithWraparound(object sender, MouseEventArgs e)
DungeonIndex = Math.EMod(newIndex, DungeonNames.Length);
SelectedDungeon.Text = DungeonNames[DungeonIndex];
SetSelectedDungeonLocation();
DragBehaviour.SaveChanges();
if (isBroadcastable && Application.OpenForms["GSTHD_DK64 Broadcast View"] != null)
{
((Medallion)Application.OpenForms["GSTHD_DK64 Broadcast View"].Controls.Find(this.Name, true)[0]).SelectedDungeon.Text = DungeonNames[DungeonIndex];
Expand Down Expand Up @@ -196,11 +200,11 @@ public MedallionState GetState()
public void SetState(MedallionState state)
{
ImageIndex = state.ImageIndex;
UpdateImage();
DungeonIndex = state.DungeonIndex;
SelectedDungeon.Text = DungeonNames[DungeonIndex];
DragBehaviour.SaveChanges();
UpdateImage();
SetSelectedDungeonLocation();
DragBehaviour.SaveChanges();
if (isBroadcastable && Application.OpenForms["GSTHD_DK64 Broadcast View"] != null)
{
((Medallion)Application.OpenForms["GSTHD_DK64 Broadcast View"].Controls.Find(this.Name, true)[0]).SelectedDungeon.Text = DungeonNames[DungeonIndex];
Expand Down Expand Up @@ -228,6 +232,8 @@ public void DecrementState()

public void ResetState()
{
ImageIndex = 0;
UpdateImage();
DungeonIndex = DefaultDungeonIndex;
SelectedDungeon.Text = DungeonNames[DungeonIndex];
SetSelectedDungeonLocation();
Expand All @@ -240,7 +246,7 @@ public void ResetState()

public void StartDragDrop()
{
var dropContent = new DragDropContent(false, ImageNames[1]);
var dropContent = new DragDropContent(DragBehaviour.AutocheckDragDrop, ImageNames[1]);
DoDragDrop(dropContent, DragDropEffects.Copy);
}

Expand Down

0 comments on commit 16dd21d

Please sign in to comment.