Skip to content

Commit

Permalink
Experimental User Friendly INI sections parsing was added
Browse files Browse the repository at this point in the history
  • Loading branch information
Wohlstand committed Feb 4, 2015
1 parent f5784da commit bbc8b78
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 6 deletions.
5 changes: 3 additions & 2 deletions LunaDLL.pro
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,9 @@ SOURCES += \
LunaDll/HardcodedGraphics/HardcodedGraphicsManager.cpp \
LunaDll/Minigames/GameboyRPG.cpp \
LunaDll/Minigames/Minigames.cpp \
LunaDll/HardcodedGraphics/HardocdeGFXMap.cpp \
LunaDll/Misc/SHMemServer.cpp
LunaDll/HardcodedGraphics/HardocodeGFXMap.cpp \
LunaDll/Misc/SHMemServer.cpp \



HEADERS += \
Expand Down
42 changes: 39 additions & 3 deletions LunaDll/HardcodedGraphics/HardcodedGraphicsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include "../libs/ini-reader/INIReader.h" //Ini files reader


std::string HardcodedGraphicsManager::root="";

HardcodedGraphicsManager::HardcodedGraphicsManager()
{}

Expand Down Expand Up @@ -61,6 +63,34 @@ int HardcodedGraphicsManager::patchGraphics(unsigned int offset_i, const char* f
return -1;
}

void HardcodedGraphicsManager::loadIniImage(unsigned int hex, unsigned int hex_m, INIReader &ini, std::string sct, std::string value)
{
std::string imageFile = ini.Get(sct, value, "");
if(imageFile.empty()) return;
imageFile = root+"graphics\\common\\"+imageFile;

const char *str = imageFile.c_str();

//Here we should load file hexKey - address, imageFile:
//is a name of image file in the <SMBX>\graphics\common
patchGraphics(hex, str);

//if mask no used - abort
if(hex_m==0) return;

//get filename of mask
for(int i=imageFile.size()-1; i>0; i--)
if(imageFile[i]=='.')
{
imageFile.insert(imageFile.begin()+i, 'm');
break;
}

imageFile = root+"graphics\\common\\"+imageFile;
const char *str2 = imageFile.c_str();
patchGraphics(hex_m, str2);
}

void HardcodedGraphicsManager::loadGraphics()
{
if(hardcoded_data_map.empty())
Expand All @@ -79,7 +109,7 @@ void HardcodedGraphicsManager::loadGraphics()
}
std::wstring smbxPath = path;
smbxPath = smbxPath.append(L"\\");
std::string root = wstr2str(smbxPath);
root = wstr2str(smbxPath);

std::string ttscrpath=root+"graphics.ini";
if( !file_existsX(ttscrpath) ) return;
Expand All @@ -91,11 +121,17 @@ void HardcodedGraphicsManager::loadGraphics()
return;
}

//Splash
loadIniImage(0x000ca018, 0 ,GraphicsINI, "splash", "game");
loadIniImage(0x00032a21, 0 ,GraphicsINI, "splash", "editor");

//Title
loadIniImage(0x002f460c, 0x002f3a8d, GraphicsINI, "title", "title");


/*
;Note: Mask should be detected automatically (file with m suffix like other stuff)
[splash]
game=editor_splash.gif
editor=big_splash.gif
loading=big_splash_loading.gif
coin_ani=editor_splash_coin.gif
coin_ani=coin.gif
Expand Down
6 changes: 5 additions & 1 deletion LunaDll/HardcodedGraphics/HardcodedGraphicsManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <string>
#include <map>
class INIReader;

class HardcodedGraphicsManager
{
Expand All @@ -27,7 +28,10 @@ class HardcodedGraphicsManager
static void buildMap();

private:
static std::map<unsigned int, int> hardcoded_data_map;
static std::map<unsigned int, int> hardcoded_data_map;

static std::string root;
static void loadIniImage(unsigned int hex, unsigned int hex_m, INIReader &ini, std::string sct, std::string value);
};

#endif

0 comments on commit bbc8b78

Please sign in to comment.