Skip to content

Commit

Permalink
1.0.1
Browse files Browse the repository at this point in the history
-Improved save/load system(1.0.0 savefiles are not compatable)
-Added UI scaling for lower resolutions
-Fixed some other small issues
  • Loading branch information
AvondaleZPR committed Jun 19, 2023
1 parent c5278b9 commit 978d569
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 23 deletions.
10 changes: 8 additions & 2 deletions core/map.as
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,13 @@ class RM_Map
this.bBeaten = json["bBeaten"];
this.bClaimed = json["bClaimed"];

iMapPackId = json["iMapPackId"];
sMapTags = json["sMapTags"];
this.iMapPackId = json["iMapPackId"];
this.sMapTags = json["sMapTags"];

if(json["iTmxId"] !is null)
{
this.iTmxId = json["iTmxId"];
}

this.iRMUI_X = json["iRMUI_X"];
this.iRMUI_Y = json["iRMUI_Y"];
Expand Down Expand Up @@ -133,6 +138,7 @@ class RM_Map
}
json["iMapPackId"] = iMapPackId;
json["sMapTags"] = sMapTags;
json["iTmxId"] = iTmxId;

json["iRMUI_X"] = iRMUI_X;
json["iRMUI_Y"] = iRMUI_Y;
Expand Down
29 changes: 23 additions & 6 deletions core/saveload.as
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
array<string> tLoadedSaveGames;
array<string> tLoadedSaveGamesPaths;
int iXddKey = 69;
int iXddKey = 10;

void SG_LoadSaveGames()
{
Expand All @@ -16,12 +16,15 @@ void SG_LoadSaveGames()
}
}

void SG_Save(RM_Game@ rmgGame)
void SG_Save(RM_Game@ rmgGame, bool bBackUp = false)
{
if(iMapsLoading > 0) {return;}

string sJson = Json::Write(rmgGame.ToJson());
IO::File fFile(IO::FromStorageFolder(rmgGame.sName + ".ROGUEMANIA"));
string sFileName = rmgGame.sName + ".ROGUEMANIA";
if (bBackUp) {sFileName += "_BACKUP";}

IO::File fFile(IO::FromStorageFolder(sFileName));
fFile.Open(IO::FileMode::Write);
fFile.WriteLine(SG_EncryptXDD(tostring(sJson), iXddKey));
fFile.Close();
Expand All @@ -30,7 +33,7 @@ void SG_Save(RM_Game@ rmgGame)
void SG_Load(const string &in sPath)
{
IO::File fFile(sPath);
fFile.Open(IO::FileMode::Read);
fFile.Open(IO::FileMode::Read);
@rmgLoadedGame = RM_Game(Json::Parse(SG_DecryptXDD(fFile.ReadToEnd(), iXddKey)));
fFile.Close();
}
Expand All @@ -41,7 +44,14 @@ string SG_EncryptXDD(const string &in sString, int iKey)

for(int i = 0; i < sString.Length; i++)
{
sNewString[i] = sNewString[i] + iKey;
if(i % 2 == 0)
{
sNewString[i] = sNewString[i] + iKey;
}
else
{
sNewString[i] = sNewString[i] - iKey;
}
}

return sNewString;
Expand All @@ -53,7 +63,14 @@ string SG_DecryptXDD(const string &in sString, int iKey)

for(int i = 0; i < sString.Length-1; i++)
{
sNewString[i] = sNewString[i] - iKey;
if(i % 2 == 0)
{
sNewString[i] = sNewString[i] - iKey;
}
else
{
sNewString[i] = sNewString[i] + iKey;
}
}

return sNewString;
Expand Down
2 changes: 1 addition & 1 deletion info.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ author = "AvondaleZPR"
category = "Game"

siteid = 398
version = "1.0.0"
version = "1.0.1"

[script]
timeout = 30000
33 changes: 22 additions & 11 deletions ui.as
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,20 @@ void RMUI_Render()
{
if (!bRMUI_IsInMenu) {return;}

int iWidth = Draw::GetWidth();
int iHeight = Draw::GetHeight();
int iWidthDifference = (1920 - Draw::GetWidth())/2;
int iHeightDifference = (1080 - Draw::GetHeight())/2;

UI::PushStyleColor(UI::Col::WindowBg, vec4(0, 0, 0, 0));
UI::SetNextWindowPos(0, 0);
UI::SetNextWindowSize(1920, 1080);
UI::SetNextWindowSize(iWidth, iHeight);
UI::Begin("NoMenuClicks", UI::WindowFlags::NoTitleBar + UI::WindowFlags::NoResize + UI::WindowFlags::NoMove + UI::WindowFlags::NoSavedSettings + UI::WindowFlags::NoBringToFrontOnFocus);
UI::End();
UI::PopStyleColor();

nvg::BeginPath();
nvg::RoundedRect(0, 0, 1920, 1080, 0);
nvg::RoundedRect(0, 0, iWidth, iHeight, 0);
nvg::FillColor(vec4(0,0,0,255));
nvg::Fill();
nvg::ClosePath();
Expand All @@ -62,7 +67,7 @@ void RMUI_Render()
iRMUI_IntroTime = iRMUI_IntroTime + 1.0;

nvg::BeginPath();
nvg::FillPaint(nvg::TexturePattern(vec2(500, 300), vec2(900, 450), 0.0, tIntro, 1.0 - (iRMUI_IntroTime / 1000) * 2));
nvg::FillPaint(nvg::TexturePattern(vec2(500-iWidthDifference/2, 300-iHeightDifference/2), vec2(900-iWidthDifference, 450-iHeightDifference), 0.0, tIntro, 1.0 - (iRMUI_IntroTime / 1000) * 2));
nvg::Fill();
nvg::ClosePath();

Expand All @@ -77,7 +82,7 @@ void RMUI_Render()
if (iRMUI_CurrentPage != RM_PAGE_GAME && iRMUI_CurrentPage != RM_PAGE_DEV && iRMUI_CurrentPage != RM_PAGE_STORE && iRMUI_CurrentPage != RM_PAGE_STATS) // Logo
{
nvg::BeginPath();
nvg::FillPaint(nvg::TexturePattern(vec2(660, 0), vec2(600, 300), 0.0, tLogo, 255.0));
nvg::FillPaint(nvg::TexturePattern(vec2(660-iWidthDifference/2, 0), vec2(600-iWidthDifference, 300-iHeightDifference), 0.0, tLogo, 255.0));
nvg::Fill();
nvg::ClosePath();
}
Expand All @@ -86,7 +91,7 @@ void RMUI_Render()
{
UI::PushStyleColor(UI::Col::WindowBg, vec4(0, 0, 0, 0));
UI::PushFont(fButton);
UI::SetNextWindowPos(1620, 0, UI::Cond::Always);
UI::SetNextWindowPos(iWidth-300, 0, UI::Cond::Always);
UI::SetNextWindowSize(300, 500);
UI::Begin("Consumables", UI::WindowFlags::NoTitleBar + UI::WindowFlags::NoResize + UI::WindowFlags::NoMove + UI::WindowFlags::NoSavedSettings);
UI::TextWrapped("Cash: $" + rmgLoadedGame.iCash);
Expand All @@ -102,8 +107,8 @@ void RMUI_Render()

UI::PushStyleColor(UI::Col::WindowBg, vec4(0, 0, 0, 0));
UI::PushFont(fButton);
UI::SetNextWindowPos(800, 300);
UI::SetNextWindowSize(1000, 800);
UI::SetNextWindowPos(800-iWidthDifference, 300-iHeightDifference);
UI::SetNextWindowSize(1000-iWidthDifference, 800-iHeightDifference);
UI::Begin("MenuButtons", UI::WindowFlags::NoTitleBar + UI::WindowFlags::NoResize + UI::WindowFlags::NoMove + UI::WindowFlags::NoSavedSettings);
if (iRMUI_CurrentPage == RM_PAGE_MAIN) { RMUI_RenderMainPage(); }
if (iRMUI_CurrentPage == RM_PAGE_LOAD) { RMUI_RenderLoadPage(); }
Expand Down Expand Up @@ -377,7 +382,7 @@ void RMUI_RenderGamePage() //ns

UI::PushStyleColor(UI::Col::WindowBg, vec4(0, 0, 0, 0));
UI::PushFont(fButton);
UI::SetNextWindowPos(0, 780, UI::Cond::Always);
UI::SetNextWindowPos(0, Draw::GetHeight()-300, UI::Cond::Always);
UI::SetNextWindowSize(180, 300);
UI::Begin("GameButtons", UI::WindowFlags::NoTitleBar + UI::WindowFlags::NoResize + UI::WindowFlags::NoMove + UI::WindowFlags::NoSavedSettings);
if (UI::ButtonColored("Store", 0, 0, 0, vec2(170,80)))
Expand Down Expand Up @@ -411,10 +416,11 @@ void RMUI_RenderLoadPage()
{
for(int i = 0; i < tLoadedSaveGames.Length; i++)
{
if (RMUI_RenderButton(tLoadedSaveGames[i]))
if (!tLoadedSaveGamesPaths[i].EndsWith("_BACKUP") && RMUI_RenderButton(tLoadedSaveGames[i]))
{
SG_Load(tLoadedSaveGamesPaths[i]);
iRMUI_CurrentPage = RM_PAGE_GAME;
SG_Save(rmgLoadedGame, true);
}
}
}
Expand Down Expand Up @@ -498,9 +504,14 @@ void RMUI_RenderSavePage()

void RMUI_RenderStorePage() //ns
{
int iWidth = Draw::GetWidth();
int iHeight = Draw::GetHeight();
int iWidthDifference = (1920 - Draw::GetWidth())/2;
int iHeightDifference = (1080 - Draw::GetHeight())/2;

UI::PushStyleColor(UI::Col::WindowBg, vec4(0, 0, 0, 0));
UI::PushFont(fButton);
UI::SetNextWindowPos(560, 395);
UI::SetNextWindowPos(560-iWidthDifference, 395-iHeightDifference);
UI::SetNextWindowSize(800, 270);
UI::Begin("StoreItems", UI::WindowFlags::NoTitleBar + UI::WindowFlags::NoResize + UI::WindowFlags::NoMove + UI::WindowFlags::NoSavedSettings);
if (UI::ButtonColored("Reroll = $" + STORE_REROLL_PRICE, 0, 0, 0, vec2(400,250)) && rmgLoadedGame.iCash >= STORE_REROLL_PRICE)
Expand All @@ -515,7 +526,7 @@ void RMUI_RenderStorePage() //ns
rmgLoadedGame.iSkips++;
}
UI::End();
UI::SetNextWindowPos(0, 980);
UI::SetNextWindowPos(0, 980-iHeightDifference*2);
UI::SetNextWindowSize(160, 100);
UI::Begin("StoreBackButton", UI::WindowFlags::NoTitleBar + UI::WindowFlags::NoResize + UI::WindowFlags::NoMove + UI::WindowFlags::NoSavedSettings);
if (UI::ButtonColored("Back", 0, 0, 0, vec2(150,80)))
Expand Down
11 changes: 8 additions & 3 deletions yoinked/mxrandom.as
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,17 @@ void PreloadRandomMapCoroutine(ref@ Data)

string CreateQueryURL(int iMapPackID = -1, const string &in sMapTags = "")
{
string url = "https://trackmania.exchange/mapsearch2/search?api=on&random=1&etags=23,37,40&tagsinc=0";
string url = "https://trackmania.exchange/mapsearch2/search?api=on&random=1&tagsinc=0";

if(sMapTags != "")
{
url += "&tags=" + sMapTags;
}
else
{
url += "&etags=4,10,23,37,40";
}

if (iMapPackID > 0)
{
url += "&mid=" + iMapPackID;
Expand Down Expand Up @@ -105,7 +110,7 @@ Net::HttpRequest@ Get(const string &in url)
Json::Value GetAsync(const string &in url)
{
auto req = Get(url);
print(url);
//print(url);
while (!req.Finished()) {
yield();
}
Expand Down Expand Up @@ -306,7 +311,7 @@ void FetchMapTags()
try {
for (uint i = 0; i < resNet.Length; i++)
{
if (resNet[i]["Name"] != "FlagRush" && resNet[i]["Name"] != "Puzzle" && resNet[i]["Name"] != "Royal")
if (resNet[i]["Name"] != "FlagRush" && resNet[i]["Name"] != "Puzzle" && resNet[i]["Name"] != "Royal" && resNet[i]["Name"] != "Arena")
{
int tagID = resNet[i]["ID"];
string tagName = resNet[i]["Name"];
Expand Down

0 comments on commit 978d569

Please sign in to comment.