Skip to content

Commit

Permalink
Add version text in title selection menu
Browse files Browse the repository at this point in the history
-Add to the .gitignore
-Update MODMOON_VERSION to "301"
-Add a simple algorithm to generate a version string from the config file, and display it in the title selection menu- I have to say, sDraw's text manipulation stuff is pretty nice :)
  • Loading branch information
Swiftloke committed Sep 29, 2018
1 parent 3615c0e commit 39a5be3
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -17,3 +17,4 @@ ModMoon.elf
ModMoon.vcxproj.filters
*.t3x
ModMoon.cia
textures/spritesheet.preview.png
4 changes: 4 additions & 0 deletions source/config.cpp
Expand Up @@ -112,12 +112,16 @@ Config::Config(string path, string filename)
delete[] buf;
in.close();
}
if(this->read("ModMoonVersion", 0) < MODMOON_VERSION)
this->write("ModMoonVersion", MODMOON_VERSION);
//if(read("ConfigFileVersion", 0) < CONFIG_FILE_VERSION) updateconfig();
}

string Config::read(string configsetting)
{
int pos = configfile.find(configsetting, 0);
if(pos == string::npos)
return "";
pos += configsetting.size() + 1; //Now pos is after the '{' of the config setting
int posb = configfile.find('}', pos);
return configfile.substr(pos, posb-pos);
Expand Down
2 changes: 1 addition & 1 deletion source/config.hpp
Expand Up @@ -4,7 +4,7 @@
#include <3ds/types.h>

#define CONFIG_FILE_VERSION 17
#define MODMOON_VERSION 30
#define MODMOON_VERSION 301
using namespace std;

class Config
Expand Down
19 changes: 18 additions & 1 deletion source/main.cpp
Expand Up @@ -9,6 +9,7 @@
#include <cmath>
#include <errno.h>
#include <algorithm>
#include <cctype>

#include <3ds.h>

Expand Down Expand Up @@ -95,6 +96,23 @@ string slotname = "";

float minusy = 0;

string getversion()
{
//After each digit, insert a period.
string version = to_string(config.read("ModMoonVersion", 0));
//Don't count the last digit.
for (unsigned int i = 0; i < version.size() - 1; i++)
{
char c = version.at(i);
if (isdigit(c))
{
version.insert(i + 1, ".");
}
}
version.insert(0, "Version: ");
return version;
}

string tid2str(u64 in)
{
stringstream out;
Expand Down Expand Up @@ -417,7 +435,6 @@ void drawtopscreen()

//Draw the title selection text
draw.settextcolor(RGBA8(165, 165, 165, 255));
//Not implemented...
draw.drawtext(": Help", 5, 240 - 40, 0.55, 0.55);
draw.drawtext(": Title selection", 5, 240 - 20, 0.55, 0.55);
//Draw the current title
Expand Down
3 changes: 2 additions & 1 deletion source/main.hpp
Expand Up @@ -89,4 +89,5 @@ bool issaltysdtitle(u64 optionaltitleid = 0);
//Returns "USA", "EUR" or "JPN"
string saltysdtidtoregion(u64 optionaltitleid = 0);
void drawtopscreen();
bool secretcodeadvance(u32 kDown);
bool secretcodeadvance(u32 kDown);
string getversion();
3 changes: 3 additions & 0 deletions source/titleselect.cpp
Expand Up @@ -110,6 +110,9 @@ void titleselectdraw(C3D_Tex prevfb, float fbinterpfactor, int scrollsubtractrow
}
draw.drawtexture(titleselectionboxes, 26, 21);
draw.drawframebuffer(prevfb, 0, 0, false, 0, -240, fbinterpfactor);
draw.settextcolor(RGBA8(165, 165, 165, 255));
string versiontext = getversion();
draw.drawtext(versiontext.c_str(), 320 - 18 - draw.gettextmaxwidth(versiontext.c_str(), .4, .5), 0, .45, .45);
draw.frameend();
}

Expand Down

0 comments on commit 39a5be3

Please sign in to comment.