forked from EasyRPG/Player
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial Ineluki Key Patch support
- Loading branch information
Showing
12 changed files
with
260 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
/* | ||
* This file is part of EasyRPG Player. | ||
* | ||
* EasyRPG Player is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* EasyRPG Player is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with EasyRPG Player. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
// Headers | ||
#include "game_ineluki.h" | ||
#include "filefinder.h" | ||
#include "inireader.h" | ||
#include "utils.h" | ||
#include "output.h" | ||
#include "audio.h" | ||
#include "input.h" | ||
|
||
Game_Ineluki::Game_Ineluki() { | ||
|
||
} | ||
|
||
bool Game_Ineluki::Execute(const RPG::Sound& se) { | ||
if (functions.find(se.name) == functions.end()) { | ||
if (!Parse(se)) { | ||
return false; | ||
} | ||
} | ||
|
||
for (const auto& cmd : functions[se.name]) { | ||
Output::Debug("Ineluki %s %s", cmd.name.c_str(), cmd.arg.c_str()); | ||
|
||
if (cmd.name == "writetolog") { | ||
Output::PostStr(cmd.arg); | ||
} else if (cmd.name == "execprogram") { | ||
Output::Warning("Ineluki ExecProgram %s: Not supported", cmd.arg.c_str()); | ||
} else if (cmd.name == "mcicommand") { | ||
Output::Warning("Ineluki MciProgram %s: Not supported", cmd.arg.c_str()); | ||
} else if (cmd.name == "miditickfunction") { | ||
std::string arg = Utils::LowerCase(cmd.arg); | ||
if (arg == "original") { | ||
output_mode = OutputMode::Original; | ||
} else if (arg == "output") { | ||
output_mode = OutputMode::Output; | ||
} else if (arg == "clear") { | ||
output_list.clear(); | ||
} | ||
} else if (cmd.name == "addoutput") { | ||
output_list.push_back(atoi(cmd.arg.c_str())); | ||
} else if (cmd.name == "enablekeysupport") { | ||
key_support = Utils::LowerCase(cmd.arg) == "true"; | ||
} else if (cmd.name == "registerkeydownevent") { | ||
// TODO | ||
} else if (cmd.name == "registerkeyupevent") { | ||
// TODO | ||
} else if (cmd.name == "enablemousesupport") { | ||
mouse_support = Utils::LowerCase(cmd.arg) == "true"; | ||
mouse_id_prefix = atoi(cmd.arg2.c_str()); | ||
// automatic | ||
} else if (cmd.name == "getmouseposition") { | ||
int mouse_x; | ||
int mouse_y; | ||
|
||
Input::GetMousePosition(mouse_x, mouse_y); | ||
|
||
bool left = Input::IsKeyPressed(Input::Keys::MOUSE_LEFT); | ||
bool right = Input::IsKeyPressed(Input::Keys::MOUSE_RIGHT); | ||
|
||
int key = left && right ? 3 : right ? 2 : left ? 1 : 0; | ||
|
||
output_list.push_back(key); | ||
output_list.push_back(mouse_y); | ||
output_list.push_back(mouse_x); | ||
output_list.push_back(mouse_id_prefix); | ||
} else if (cmd.name == "setdebuglevel") { | ||
// no-op | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
|
||
bool Game_Ineluki::Parse(const RPG::Sound& se) { | ||
std::string ini_file = FileFinder::FindSound(se.name); | ||
|
||
INIReader ini(ini_file); | ||
if (ini.ParseError() == -1) { | ||
return false; | ||
} | ||
|
||
command_list commands; | ||
std::string section = "execute"; | ||
|
||
do { | ||
InelukiCommand cmd; | ||
cmd.name = Utils::LowerCase(ini.Get(section, "action", std::string())); | ||
bool valid = true; | ||
|
||
if (cmd.name == "writetolog") { | ||
cmd.arg = ini.Get(section, "text", std::string()); | ||
} else if (cmd.name == "execprogram") { | ||
cmd.arg = ini.Get(section, "command", std::string()); | ||
} else if (cmd.name == "mcicommand") { | ||
cmd.arg = ini.Get(section, "command", std::string()); | ||
} else if (cmd.name == "miditickfunction") { | ||
cmd.arg = ini.Get(section, "command", std::string()); | ||
if (cmd.arg.empty()) { | ||
cmd.arg = ini.Get(section, "value", std::string()); | ||
} | ||
} else if (cmd.name == "addoutput") { | ||
cmd.arg = ini.Get(section, "value", std::string()); | ||
} else if (cmd.name == "enablekeysupport") { | ||
cmd.arg = ini.Get(section, "enable", std::string()); | ||
} else if (cmd.name == "registerkeydownevent") { | ||
cmd.arg = ini.Get(section, "key", std::string()); | ||
cmd.arg2 = ini.Get(section, "value", std::string()); | ||
} else if (cmd.name == "registerkeyupevent") { | ||
cmd.arg = ini.Get(section, "key", std::string()); | ||
cmd.arg2 = ini.Get(section, "value", std::string()); | ||
} else if (cmd.name == "enablemousesupport") { | ||
cmd.arg = ini.Get(section, "enable", std::string()); | ||
cmd.arg2 = ini.Get(section, "id", std::string()); | ||
cmd.arg3 = ini.Get(section, "automatic", std::string()); | ||
} else if (cmd.name == "getmouseposition") { | ||
// no args | ||
} else if (cmd.name == "setdebuglevel") { | ||
cmd.arg = ini.Get(section, "level", std::string()); | ||
} else { | ||
valid = false; | ||
} | ||
|
||
if (valid) { | ||
commands.push_back(cmd); | ||
} | ||
|
||
section = ini.Get(section, "next", std::string()); | ||
} while (!section.empty()); | ||
|
||
functions[se.name] = commands; | ||
|
||
return true; | ||
} | ||
|
||
int Game_Ineluki::GetMidiTicks() { | ||
if (output_mode == OutputMode::Original) { | ||
return Audio().BGM_GetTicks(); | ||
} else { | ||
int val = 0; | ||
if (!output_list.empty()) { | ||
val = output_list.back(); | ||
output_list.pop_back(); | ||
} | ||
return val; | ||
} | ||
} | ||
|
||
void Game_Ineluki::Update() { | ||
if (mouse_support) { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* This file is part of EasyRPG Player. | ||
* | ||
* EasyRPG Player is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* EasyRPG Player is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with EasyRPG Player. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef EP_GAME_INELUKI_H | ||
#define EP_GAME_INELUKI_H | ||
|
||
// Headers | ||
#include <string> | ||
#include <vector> | ||
#include <map> | ||
|
||
#include "rpg_sound.h" | ||
|
||
class Game_Ineluki { | ||
public: | ||
Game_Ineluki(); | ||
|
||
bool Execute(const RPG::Sound& se); | ||
|
||
int GetMidiTicks(); | ||
|
||
void Update(); | ||
|
||
private: | ||
bool Parse(const RPG::Sound& se); | ||
|
||
struct InelukiCommand { | ||
std::string name; | ||
std::string arg; | ||
std::string arg2; | ||
std::string arg3; | ||
}; | ||
|
||
using command_list = std::vector<InelukiCommand>; | ||
|
||
std::map<std::string, command_list> functions; | ||
|
||
enum class OutputMode { | ||
Original, | ||
Output | ||
}; | ||
|
||
OutputMode output_mode = OutputMode::Original; | ||
std::vector<int> output_list; | ||
|
||
bool key_support = false; | ||
bool mouse_support = false; | ||
int mouse_id_prefix = 0; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.