Skip to content

Commit

Permalink
Added quest-editing; refactorings:
Browse files Browse the repository at this point in the history
- removed unnecessary"this"
- removed some more constructors
  • Loading branch information
tolik518 committed Feb 19, 2024
1 parent bc16278 commit 993bf63
Show file tree
Hide file tree
Showing 10 changed files with 246 additions and 31 deletions.
8 changes: 4 additions & 4 deletions SoG_SGreader/DataReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public static Player ReadFromFile(string fileName, ITextBoxWrapper txtConsole)
{
playerObject.Quests.Add(new Quest
{
QuestID = readBinary.ReadUInt16()
QuestID = (SogQuests)readBinary.ReadUInt16()
});
}
txtConsole.AppendText("\r\n" + "QuestsCount: " + playerObject.QuestsCount);
Expand All @@ -241,9 +241,9 @@ public static Player ReadFromFile(string fileName, ITextBoxWrapper txtConsole)
for (int i = 0; i != playerObject.EnemiesMetCount; i++)
{
playerObject.Enemies.Add(new Enemy
(
readBinary.ReadInt32()
));
{
EnemyID = readBinary.ReadInt32()
});
}
txtConsole.AppendText("\r\n" + "EnemiesMetCount: " + playerObject.EnemiesMetCount);

Expand Down
2 changes: 1 addition & 1 deletion SoG_SGreader/DataWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public void WriteToFile(string fileName)
writeBinary.Write(playerObject.QuestsCount);
for (int i = 0; i != playerObject.QuestsCount; i++)
{
writeBinary.Write(playerObject.Quests[i].QuestID);
writeBinary.Write((ushort)playerObject.Quests[i].QuestID);
}

writeBinary.Write(playerObject.EnemiesMetCount);
Expand Down
93 changes: 93 additions & 0 deletions SoG_SGreader/Enum/SogQuests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
namespace SoG_SGreader
{
// Source: Secrets of Grindea: SoG.QuestCodex
// Game Version: 0.99g
public enum SogQuests : ushort
{
MainQuest_FirstVillage_FindApples = 0,
MainQuest_FirstVillage_GearUp = 1,
MainQuest_SkyTemple_GetToSkyTemple = 2,
MainQuest_PumpkinWoods_GhostHunt = 3,
MainQuest_PostSkyTemple_MarinoAmulet = 4,
MainQuest_SeasonTemple_MainArc = 5,
MainQuest_SeasonTemple_ToyFactoryQuest = 6,
MainQuest_PostSeasonTemple_FestivalPreparations = 7,
MainQuest_TimeTemple_MainArc_OldVersion = 8,
MainQuest_MtBloom_FirstRequest = 9,
MainQuest_MtBloom_SecondRequest = 10,
MainQuest_TaiMing_TheThousandYearAle = 11,
MainQuest_TaiMing_TheSecretsOfMana = 12,
MainQuest_TimeTemple_MainArc = 13,
MainQuest_TaiMing_TreasureForAKing = 14,
MainQuest_EvergrindCity_TheCollectorsExam = 15,
MainQuest_Desert_WhatFloatsYourBoat = 16,
MainQuest_Desert_AFarePrice = 17,
MainQuest_GhostShip_AGhastlyGathering = 18,
MainQuest_EndGame_AscentIntoMadness = 19,
SideQuest_Knark = 10000,
SideQuest_SlimeAndRing = 10001,
SideQuest_CookingWitchCandy = 10002,
SideQuest_ForOldTimes = 10003,
SideQuest_PumpkinInspection = 10004,
SideQuest_StartingtonChickenCatcher = 10005,
SideQuest_EvergrindFieldsCarrotSword = 10006,
SideQuest_ChickenSavior = 10007,
SideQuest_PoorThanksgiving = 10008,
SideQuest_BeatsByWyl = 10009,
SideQuest_TheLonelyScarecrow = 10010,
SideQuest_TheGoblinGrinch = 10011,
SideQuest_SplitTheBill = 10012,
SideQuest_FaerlyBrave = 10013,
SideQuest_PetDetective = 10014,
SideQuest_SteveGetsFired = 10015,
SideQuest_CrystalClear = 10016,
SideQuest_TheAlchemistsApprentice = 10017,
SideQuest_GoneWithTheWind = 10018,
SideQuest_TheMuseumIsClosed = 10019,
SideQuest_IceCreamRun = 10020,
SideQuest_TheLostCatPic = 10021,
SideQuest_Vanjie = 10022,
SideQuest_ForExposure = 10023,
SideQuest_ForMoreExposure = 10024,
SideQuest_ForMostExposure = 10025,
SideQuest_FinderKeepsHers = 10026,
SideQuest_GroceryRun = 10027,
SideQuest_TheSpectralBall_OBSOLETE = 10028,
SideQuest_TheSpectralBall_MK2_OBSOLETE = 10029,
SideQuest_PhaseOff = 10030,
SideQuest_Butterflown = 10031,
SideQuest_OneMeaslySlime = 10032,
SideQuest_AWordFromOurSponsors = 10033,
SideQuest_BloomyBarnBrawl = 10034,
SideQuest_TheRemedy = 10035,
SideQuest_LeafingHome = 10036,
SideQuest_CareerChange = 10037,
SideQuest_TheSpectralBall_MK3 = 10038,
RogueLikeQuest_FindCarpenterHammer = 20000,
RogueLikeQuest_FindStonecutterMaterials = 20001,
RogueLikeQuest_HalloweedPollenForGardener = 20002,
RogueLikeQuest_GiantsEssenceForPlott = 20003,
RogueLikeQuest_GrindeaChallenge01 = 20004,
RogueLikeQuest_GrindeaChallenge02 = 20005,
RogueLikeQuest_ButterflyCatcher = 20006,
RogueLikeQuest_BartenderFluQuest = 20007,
RogueLikeQuest_HaddockRedFishQuest = 20008,
RogueLikeQuest_OldmanRedGigaSlime = 20009,
RogueLikeQuest_CarpenterFirstHuntingQuest = 20010,
RogueLikeQuest_FindCandyForMuffinQuest = 20011,
RogueLikeQuest_DistressSignal = 20012,
RogueLikeQuest_TameARabby = 20013,
RogueLikeQuest_RobinHuntingQuest = 20014,
RogueLikeQuest_LoodHunt = 20015,
RogueLikeQuest_GrindeaChallenge03 = 20016,
RogueLikeQuest_GrindeaChallenge04 = 20017,
RogueLikeQuest_WhereAreTheBirds = 20018,
RogueLikeQuest_BlindChase = 20019,
RogueLikeQuest_FindTheFinder = 20020,
RogueLikeQuest_HomeAwayFromHome = 20021,
RogueLikeQuest_ASmashingPhoto = 20022,
RogueLikeQuest_PumpkinMixer = 20023,
RogueLikeQuest_BoringTheElder = 20024,
None = 44000,
}
}
8 changes: 4 additions & 4 deletions SoG_SGreader/Forms/FrmLoadSaveGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ private void BtnLoadSaveGame_Click(object sender, EventArgs e)
filePath = Path.Combine(filePath, lstvSaveGames.SelectedItems[0].Text);
}
FrmMain frmMain = new FrmMain(filePath);
this.Hide();
Hide();
frmMain.ShowDialog();
this.Close();
Close();
}

private void GetSaveGameFiles(string sFilePath)
Expand Down Expand Up @@ -75,9 +75,9 @@ private void BtnChooseFolder_Click(object sender, EventArgs e)
private void BtnStartWithoitLoading_Click(object sender, EventArgs e)
{
FrmMain frmMain = new FrmMain("");
this.Hide();
Hide();
frmMain.ShowDialog();
this.Close();
Close();
}

private void UpdateFilePathLabel()
Expand Down
77 changes: 63 additions & 14 deletions SoG_SGreader/Forms/FrmMain.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 51 additions & 2 deletions SoG_SGreader/Forms/FrmMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ private void InitFields()
//fill cblstCards with all the cards from Enemies enum
var cards = Enum.GetNames(typeof(SogEnemies));
cblstCards.DataSource = cards;

var quests = Enum.GetNames(typeof(SogQuests));
cblstQuests.DataSource = quests;
}

private void PopulateFields()
Expand Down Expand Up @@ -285,6 +288,13 @@ private void PopulateFields()
bool playerHasCard = playerObject.HasCard((SogEnemies)Enum.Parse(typeof(SogEnemies), cblstCards.Items[i].ToString()));
cblstCards.SetItemChecked(i, playerHasCard);
}

// find out if player has the Quest. mark the checkbox if yes
for (int i = 0; i < cblstQuests.Items.Count; i++)
{
bool playerHasQuest = playerObject.HasQuest((SogQuests)Enum.Parse(typeof(SogQuests), cblstQuests.Items[i].ToString()));
cblstQuests.SetItemChecked(i, playerHasQuest);
}
}

//TODO: we need to clean all our variables before we load a new file
Expand Down Expand Up @@ -410,6 +420,20 @@ private void GetDataFromFields()
);
}
}

playerObject.Quests.Clear();
for (int i = 0; i < cblstQuests.Items.Count; i++)
{
if (cblstQuests.GetItemChecked(i))
{
playerObject.Quests.Add(
new Quest
{
QuestID = (SogQuests)Enum.Parse(typeof(SogQuests), cblstQuests.Items[i].ToString())
}
);
}
}
}

private void LstInventory_SelectedIndexChanged(object sender, EventArgs e)
Expand Down Expand Up @@ -441,7 +465,7 @@ private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
fileStream.Close();
}

this.GetDataFromFields();
GetDataFromFields();
DataWriter dataWriter = new DataWriter(playerObject);
dataWriter.WriteToFile(sFilename);

Expand Down Expand Up @@ -657,7 +681,7 @@ private void PictureBox3_Click(object sender, EventArgs e) //:3 Icon in the top

private async void FrmMain_Load(object sender, EventArgs e)
{
this.Text = "SoG: Savegame Editor v" + Application.ProductVersion + " by tolik518";
Text = "SoG: Savegame Editor v" + Application.ProductVersion + " by tolik518";

ITextBoxWrapper txtConsoleWrapped = new UITextBox(txtConsole);

Expand Down Expand Up @@ -702,5 +726,30 @@ private void btnDeselectAllCards_Click(object sender, EventArgs e)
cblstCards.SetItemChecked(i, false);
}
}

private void btnResetQuests_Click(object sender, EventArgs e)
{
for (int i = 0; i < cblstQuests.Items.Count; i++)
{
bool playerHasQuest = playerObject.HasQuest((SogQuests)Enum.Parse(typeof(SogQuests), cblstQuests.Items[i].ToString()));
cblstQuests.SetItemChecked(i, playerHasQuest);
}
}

private void btnSelectAllQuests_Click(object sender, EventArgs e)
{
for (int i = 0; i < cblstQuests.Items.Count; i++)
{
cblstQuests.SetItemChecked(i, true);
}
}

private void btnDeselectAllQuests_Click(object sender, EventArgs e)
{
for (int i = 0; i < cblstQuests.Items.Count; i++)
{
cblstQuests.SetItemChecked(i, false);
}
}
}
}
5 changes: 0 additions & 5 deletions SoG_SGreader/Objects/Enemy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,5 @@ namespace SoG_SGreader
public class Enemy
{
public int EnemyID { get; set; }

public Enemy(int enemyId)
{
this.EnemyID = enemyId;
}
}
}
Loading

0 comments on commit 993bf63

Please sign in to comment.