Compare commits
No commits in common. "58fd1a37a8652348bf878dddd4773f8e18fd5b8a" and "3a80fab3ddcf26d56517f928cbd542ce112ebf2d" have entirely different histories.
58fd1a37a8
...
3a80fab3dd
@ -15,14 +15,16 @@ FSLib::Directory::Directory(const string &path_) : dir_path(path_) {}
|
|||||||
FSLib::Directory::Iterator::Iterator( const Directory &d_ )
|
FSLib::Directory::Iterator::Iterator( const Directory &d_ )
|
||||||
: d( opendir( d_.path() ) ) {
|
: d( opendir( d_.path() ) ) {
|
||||||
if ( !exists( d_.path() ) || !isDirectory( d_.path() ) ) {
|
if ( !exists( d_.path() ) || !isDirectory( d_.path() ) ) {
|
||||||
throw std::runtime_error(std::string("Directory ") + d_.path() +
|
throw std::runtime_error(
|
||||||
|
std::string( "Directory " ) + d_.path() +
|
||||||
" either doesn't exist or isn't a directory" );
|
" either doesn't exist or isn't a directory" );
|
||||||
}
|
}
|
||||||
|
|
||||||
current_entry = readdir( d );
|
current_entry = readdir( d );
|
||||||
|
|
||||||
// skip "." and ".."
|
// skip "." and ".."
|
||||||
if (current_entry != nullptr && (!strcmp(current_entry->d_name, ".") ||
|
if ( current_entry != nullptr &&
|
||||||
|
( !strcmp( current_entry->d_name, "." ) ||
|
||||||
!strcmp( current_entry->d_name, ".." ) ) )
|
!strcmp( current_entry->d_name, ".." ) ) )
|
||||||
++( *this );
|
++( *this );
|
||||||
}
|
}
|
||||||
@ -136,7 +138,8 @@ FSLib::Directory::Iterator &FSLib::Directory::Iterator::operator++() {
|
|||||||
return *this;
|
return *this;
|
||||||
current_entry = readdir( d );
|
current_entry = readdir( d );
|
||||||
// skip . and ..
|
// skip . and ..
|
||||||
if (current_entry != nullptr && (!strcmp(current_entry->d_name, ".") ||
|
if ( current_entry != nullptr &&
|
||||||
|
( !strcmp( current_entry->d_name, "." ) ||
|
||||||
!strcmp( current_entry->d_name, ".." ) ) )
|
!strcmp( current_entry->d_name, ".." ) ) )
|
||||||
return operator++();
|
return operator++();
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -18,7 +18,8 @@ FSLib::Directory::Iterator::Iterator(const Directory &d_) {
|
|||||||
}
|
}
|
||||||
hFind = FindFirstFileW( d_.path(), &data );
|
hFind = FindFirstFileW( d_.path(), &data );
|
||||||
if ( hFind != INVALID_HANDLE_VALUE ) {
|
if ( hFind != INVALID_HANDLE_VALUE ) {
|
||||||
if (!wcscmp(data.cFileName, L".") || !wcscmp(data.cFileName, L"..")) {
|
if ( !wcscmp( data.cFileName, L"." ) ||
|
||||||
|
!wcscmp( data.cFileName, L".." ) ) {
|
||||||
++( *this );
|
++( *this );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
12
mario/gui/gui.cpp
Normal file
12
mario/gui/gui.cpp
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#include "gui.hpp"
|
||||||
|
|
||||||
|
/*std::shared_ptr<SDLPP::RectangleRender>
|
||||||
|
createButton(double x, double y, double w, double h,
|
||||||
|
std::shared_ptr<SDLPP::Renderer> &r, const std::string &text,
|
||||||
|
const std::string &color, const std::string &outline_color,
|
||||||
|
const std::string &background_color,
|
||||||
|
std::function<void(void *)> click_fun, void *input) {
|
||||||
|
auto button = std::make_shared<Button>(
|
||||||
|
x, y, w, h, r, text, color, outline_color, background_color, click_fun, input);
|
||||||
|
return std::static_pointer_cast<SDLPP::RectangleRender>(button);
|
||||||
|
}*/
|
@ -33,9 +33,8 @@ public:
|
|||||||
std::shared_ptr<SDLPP::Renderer> &r, const std::string &text,
|
std::shared_ptr<SDLPP::Renderer> &r, const std::string &text,
|
||||||
const ButtonConfig &config,
|
const ButtonConfig &config,
|
||||||
std::function<void(void *, Button *)> click_fun, void *input)
|
std::function<void(void *, Button *)> click_fun, void *input)
|
||||||
: TextRenderer(x, y, w, h, r, g_text_config->getFont(), text,
|
: TextRenderer(x, y, w, h, r, g_text_config->getFont(), text, config.font_color,
|
||||||
config.font_color, config.font_outline_color,
|
config.font_outline_color, config.outline),
|
||||||
config.outline),
|
|
||||||
click_fun(std::move(click_fun)), func_input(input),
|
click_fun(std::move(click_fun)), func_input(input),
|
||||||
config(config), button_text(text) {
|
config(config), button_text(text) {
|
||||||
setColor(config.bg_color);
|
setColor(config.bg_color);
|
||||||
@ -151,18 +150,13 @@ public:
|
|||||||
if(should_update_color) {
|
if(should_update_color) {
|
||||||
switch(state) {
|
switch(state) {
|
||||||
case NORMAL:
|
case NORMAL:
|
||||||
setTextColor(g_text_config->getFont(), config.font_color,
|
setTextColor(g_text_config->getFont(), config.font_color, config.font_outline_color, config.outline);
|
||||||
config.font_outline_color, config.outline);
|
|
||||||
break;
|
break;
|
||||||
case HIGHLIGHTED:
|
case HIGHLIGHTED:
|
||||||
setTextColor(
|
setTextColor(g_text_config->getFont(), config.font_color_highlight, config.font_outline_color_highlight, config.outline);
|
||||||
g_text_config->getFont(), config.font_color_highlight,
|
|
||||||
config.font_outline_color_highlight, config.outline);
|
|
||||||
break;
|
break;
|
||||||
case DISABLED:
|
case DISABLED:
|
||||||
setTextColor(
|
setTextColor(g_text_config->getFont(), config.font_color_disabled, config.font_outline_color_disabled, config.outline);
|
||||||
g_text_config->getFont(), config.font_color_disabled,
|
|
||||||
config.font_outline_color_disabled, config.outline);
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -171,7 +165,6 @@ public:
|
|||||||
changeText(button_text);
|
changeText(button_text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::function<void(void *, Button *)> click_fun;
|
std::function<void(void *, Button *)> click_fun;
|
||||||
void *func_input;
|
void *func_input;
|
||||||
|
@ -118,8 +118,7 @@ void loadMap(std::shared_ptr<SDLPP::Scene> &scene,
|
|||||||
map_file.read((char *)&version, sizeof(uint16_t) / sizeof(char));
|
map_file.read((char *)&version, sizeof(uint16_t) / sizeof(char));
|
||||||
switch(version) {
|
switch(version) {
|
||||||
case 0x01:
|
case 0x01:
|
||||||
loadMapV01(scene, mario, map_file, objects, editor, editor_width,
|
loadMapV01(scene, mario, map_file, objects, editor, editor_width, renderer);
|
||||||
renderer);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw "Invalid file version";
|
throw "Invalid file version";
|
||||||
@ -223,6 +222,7 @@ void loadMapV01(std::shared_ptr<SDLPP::Scene> &scene,
|
|||||||
if (editor && objects.size() < editor_width) {
|
if (editor && objects.size() < editor_width) {
|
||||||
objects.resize(editor_width);
|
objects.resize(editor_width);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO catch exception in calling func
|
// TODO catch exception in calling func
|
||||||
|
@ -126,8 +126,7 @@ SceneStruct mainMenuScene;
|
|||||||
std::shared_ptr<SDLPP::TextRenderer> global_test_text{};
|
std::shared_ptr<SDLPP::TextRenderer> global_test_text{};
|
||||||
std::string global_test_text_text{};
|
std::string global_test_text_text{};
|
||||||
|
|
||||||
void openMapEditor(std::shared_ptr<SDLPP::Scene> &scene,
|
void openMapEditor(std::shared_ptr<SDLPP::Scene> &scene, const std::string &filename);
|
||||||
const std::string &filename);
|
|
||||||
|
|
||||||
void setFlag(uint64_t flag) {
|
void setFlag(uint64_t flag) {
|
||||||
global_vars.flags |= flag;
|
global_vars.flags |= flag;
|
||||||
@ -250,8 +249,7 @@ void unsetToolColor() {
|
|||||||
setToolColor("#FFFFFF00");
|
setToolColor("#FFFFFF00");
|
||||||
}
|
}
|
||||||
|
|
||||||
void toolMoveUpdateButtons(Button *left, Button *right, int &cur_page,
|
void toolMoveUpdateButtons(Button *left, Button *right, int &cur_page, int &max_page, bool canAdd) {
|
||||||
int &max_page, bool canAdd) {
|
|
||||||
if(cur_page == 0) {
|
if(cur_page == 0) {
|
||||||
left->disable();
|
left->disable();
|
||||||
} else {
|
} else {
|
||||||
@ -291,26 +289,19 @@ void updateToolSelection(int prev_index, ToolType::Value type) {
|
|||||||
cur_page = global_vars.tool.cur_page_tools;
|
cur_page = global_vars.tool.cur_page_tools;
|
||||||
multiplier = 2 * TOOLS_WIDTH;
|
multiplier = 2 * TOOLS_WIDTH;
|
||||||
tool_vec = &global_vars.tools;
|
tool_vec = &global_vars.tools;
|
||||||
toolMoveUpdateButtons(global_vars.tool.button_left_tools.get(),
|
toolMoveUpdateButtons(global_vars.tool.button_left_tools.get(), global_vars.tool.button_right_tools.get(), cur_page, global_vars.tool.max_page_tools, false);
|
||||||
global_vars.tool.button_right_tools.get(),
|
|
||||||
cur_page, global_vars.tool.max_page_tools, false);
|
|
||||||
break;
|
break;
|
||||||
case ToolType::MOD:
|
case ToolType::MOD:
|
||||||
cur_page = global_vars.tool.cur_page_mods;
|
cur_page = global_vars.tool.cur_page_mods;
|
||||||
multiplier = 2 * MOD_WIDTH;
|
multiplier = 2 * MOD_WIDTH;
|
||||||
tool_vec = &global_vars.mods;
|
tool_vec = &global_vars.mods;
|
||||||
toolMoveUpdateButtons(global_vars.tool.button_left_mods.get(),
|
toolMoveUpdateButtons(global_vars.tool.button_left_mods.get(), global_vars.tool.button_right_mods.get(), cur_page, global_vars.tool.max_page_mods, false);
|
||||||
global_vars.tool.button_right_mods.get(),
|
|
||||||
cur_page, global_vars.tool.max_page_mods, false);
|
|
||||||
break;
|
break;
|
||||||
case ToolType::CHARACTER:
|
case ToolType::CHARACTER:
|
||||||
cur_page = global_vars.tool.cur_page_characters;
|
cur_page = global_vars.tool.cur_page_characters;
|
||||||
multiplier = 2 * CHARACTER_WIDTH;
|
multiplier = 2 * CHARACTER_WIDTH;
|
||||||
tool_vec = &global_vars.characters;
|
tool_vec = &global_vars.characters;
|
||||||
toolMoveUpdateButtons(global_vars.tool.button_left_characters.get(),
|
toolMoveUpdateButtons(global_vars.tool.button_left_characters.get(), global_vars.tool.button_right_characters.get(), cur_page, global_vars.tool.max_page_characters, false);
|
||||||
global_vars.tool.button_right_characters.get(),
|
|
||||||
cur_page, global_vars.tool.max_page_characters,
|
|
||||||
false);
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -577,8 +568,7 @@ void getMousePositionFlags(SDLPP::Scene &scene) {
|
|||||||
scene.visitCollisions(*mouse, visitor);
|
scene.visitCollisions(*mouse, visitor);
|
||||||
if(visitor.getCurButton() != global_vars.mouse.cur_button_index) {
|
if(visitor.getCurButton() != global_vars.mouse.cur_button_index) {
|
||||||
if(global_vars.mouse.cur_button_index != (uint64_t)-1) {
|
if(global_vars.mouse.cur_button_index != (uint64_t)-1) {
|
||||||
global_vars.buttons[global_vars.mouse.cur_button_index]
|
global_vars.buttons[global_vars.mouse.cur_button_index]->unsetHighlight();
|
||||||
->unsetHighlight();
|
|
||||||
}
|
}
|
||||||
if(visitor.getCurButton() != (uint64_t)-1) {
|
if(visitor.getCurButton() != (uint64_t)-1) {
|
||||||
global_vars.buttons[visitor.getCurButton()]->setHighlight();
|
global_vars.buttons[visitor.getCurButton()]->setHighlight();
|
||||||
@ -601,13 +591,11 @@ void getMousePositionFlags(SDLPP::Scene &scene) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void toolMoveLeft(Button *left, Button *right, int &cur_page, int &max_page,
|
void toolMoveLeft(Button *left, Button *right, int &cur_page, int &max_page, bool canAdd) {
|
||||||
bool canAdd) {
|
|
||||||
cur_page--;
|
cur_page--;
|
||||||
toolMoveUpdateButtons(left, right, cur_page, max_page, canAdd);
|
toolMoveUpdateButtons(left, right, cur_page, max_page, canAdd);
|
||||||
}
|
}
|
||||||
void toolMoveRight(Button *left, Button *right, int &cur_page, int &max_page,
|
void toolMoveRight(Button *left, Button *right, int &cur_page, int &max_page, bool canAdd) {
|
||||||
bool canAdd) {
|
|
||||||
cur_page += 1;
|
cur_page += 1;
|
||||||
toolMoveUpdateButtons(left, right, cur_page, max_page, canAdd);
|
toolMoveUpdateButtons(left, right, cur_page, max_page, canAdd);
|
||||||
}
|
}
|
||||||
@ -615,8 +603,7 @@ void toolMoveRight(Button *left, Button *right, int &cur_page, int &max_page,
|
|||||||
void moveMapLeft(void *input, Button *caller) {
|
void moveMapLeft(void *input, Button *caller) {
|
||||||
auto actual_input = static_cast<moveStruct*>(input);
|
auto actual_input = static_cast<moveStruct*>(input);
|
||||||
actual_input->scene->moveEverything(BLOCK_SIZE, 0);
|
actual_input->scene->moveEverything(BLOCK_SIZE, 0);
|
||||||
toolMoveLeft(caller, actual_input->other_button.get(),
|
toolMoveLeft(caller, actual_input->other_button.get(), global_vars.map.cur_page, global_vars.map.max_page, true);
|
||||||
global_vars.map.cur_page, global_vars.map.max_page, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void moveMapRight(void *input, Button *caller) {
|
void moveMapRight(void *input, Button *caller) {
|
||||||
@ -625,65 +612,55 @@ void moveMapRight(void *input, Button *caller) {
|
|||||||
global_vars.objects.resize(global_vars.objects.size() + 1);
|
global_vars.objects.resize(global_vars.objects.size() + 1);
|
||||||
global_vars.map.max_page++;
|
global_vars.map.max_page++;
|
||||||
}
|
}
|
||||||
toolMoveRight(actual_input->other_button.get(), caller,
|
toolMoveRight(actual_input->other_button.get(), caller, global_vars.map.cur_page, global_vars.map.max_page, true);
|
||||||
global_vars.map.cur_page, global_vars.map.max_page, true);
|
|
||||||
actual_input->scene->moveEverything(-BLOCK_SIZE, 0);
|
actual_input->scene->moveEverything(-BLOCK_SIZE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void moveToolsLeftButton(void *input, Button *caller) {
|
void moveToolsLeftButton(void *input, Button *caller) {
|
||||||
auto actual_input = static_cast<moveStruct*>(input);
|
auto actual_input = static_cast<moveStruct*>(input);
|
||||||
toolMoveLeft(caller, actual_input->other_button.get(),
|
toolMoveLeft(caller, actual_input->other_button.get(), global_vars.tool.cur_page_tools, global_vars.tool.max_page_tools, false);
|
||||||
global_vars.tool.cur_page_tools,
|
updateToolSelection(global_vars.tool.cur_page_tools + 1,
|
||||||
global_vars.tool.max_page_tools, false);
|
ToolType::BLOCK);
|
||||||
updateToolSelection(global_vars.tool.cur_page_tools + 1, ToolType::BLOCK);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void moveToolsRightButton(void *input, Button *caller) {
|
void moveToolsRightButton(void *input, Button *caller) {
|
||||||
auto actual_input = static_cast<moveStruct*>(input);
|
auto actual_input = static_cast<moveStruct*>(input);
|
||||||
toolMoveRight(actual_input->other_button.get(), caller,
|
toolMoveRight(actual_input->other_button.get(), caller, global_vars.tool.cur_page_tools, global_vars.tool.max_page_tools, false);
|
||||||
global_vars.tool.cur_page_tools,
|
updateToolSelection(global_vars.tool.cur_page_tools - 1,
|
||||||
global_vars.tool.max_page_tools, false);
|
ToolType::BLOCK);
|
||||||
updateToolSelection(global_vars.tool.cur_page_tools - 1, ToolType::BLOCK);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void moveModsLeft(void *input, Button *caller) {
|
void moveModsLeft(void *input, Button *caller) {
|
||||||
auto actual_input = static_cast<moveStruct*>(input);
|
auto actual_input = static_cast<moveStruct*>(input);
|
||||||
toolMoveLeft(caller, actual_input->other_button.get(),
|
toolMoveLeft(caller, actual_input->other_button.get(), global_vars.tool.cur_page_mods, global_vars.tool.max_page_mods, false);
|
||||||
global_vars.tool.cur_page_mods, global_vars.tool.max_page_mods,
|
updateToolSelection(global_vars.tool.cur_page_tools + 1,
|
||||||
false);
|
ToolType::MOD);
|
||||||
updateToolSelection(global_vars.tool.cur_page_tools + 1, ToolType::MOD);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void moveModsRight(void *input, Button *caller) {
|
void moveModsRight(void *input, Button *caller) {
|
||||||
auto actual_input = static_cast<moveStruct*>(input);
|
auto actual_input = static_cast<moveStruct*>(input);
|
||||||
toolMoveRight(actual_input->other_button.get(), caller,
|
toolMoveRight(actual_input->other_button.get(), caller, global_vars.tool.cur_page_mods, global_vars.tool.max_page_mods, false);
|
||||||
global_vars.tool.cur_page_mods,
|
updateToolSelection(global_vars.tool.cur_page_tools - 1,
|
||||||
global_vars.tool.max_page_mods, false);
|
ToolType::MOD);
|
||||||
updateToolSelection(global_vars.tool.cur_page_tools - 1, ToolType::MOD);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void moveCharsLeft(void *input, Button *caller) {
|
void moveCharsLeft(void *input, Button *caller) {
|
||||||
auto actual_input = static_cast<moveStruct*>(input);
|
auto actual_input = static_cast<moveStruct*>(input);
|
||||||
toolMoveLeft(caller, actual_input->other_button.get(),
|
toolMoveLeft(caller, actual_input->other_button.get(), global_vars.tool.cur_page_characters, global_vars.tool.max_page_characters, false);
|
||||||
global_vars.tool.cur_page_characters,
|
|
||||||
global_vars.tool.max_page_characters, false);
|
|
||||||
updateToolSelection(global_vars.tool.cur_page_tools + 1,
|
updateToolSelection(global_vars.tool.cur_page_tools + 1,
|
||||||
ToolType::CHARACTER);
|
ToolType::CHARACTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
void moveCharsRight(void *input, Button *caller) {
|
void moveCharsRight(void *input, Button *caller) {
|
||||||
auto actual_input = static_cast<moveStruct*>(input);
|
auto actual_input = static_cast<moveStruct*>(input);
|
||||||
toolMoveRight(actual_input->other_button.get(), caller,
|
toolMoveRight(actual_input->other_button.get(), caller, global_vars.tool.cur_page_characters, global_vars.tool.max_page_characters, false);
|
||||||
global_vars.tool.cur_page_characters,
|
|
||||||
global_vars.tool.max_page_characters, false);
|
|
||||||
updateToolSelection(global_vars.tool.cur_page_tools - 1,
|
updateToolSelection(global_vars.tool.cur_page_tools - 1,
|
||||||
ToolType::CHARACTER);
|
ToolType::CHARACTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mouseUpAction(uint64_t flags) {
|
void mouseUpAction(uint64_t flags) {
|
||||||
if(MouseVisitor::button(flags)) {
|
if(MouseVisitor::button(flags)) {
|
||||||
global_vars.buttons[global_vars.mouse.cur_button_index]
|
global_vars.buttons[global_vars.mouse.cur_button_index]->performFunction();
|
||||||
->performFunction();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -805,8 +782,7 @@ void pollEvents(std::shared_ptr<SDLPP::Scene> &scene) {
|
|||||||
if(!getFlag(TEXT_INPUT_FLAG)) {
|
if(!getFlag(TEXT_INPUT_FLAG)) {
|
||||||
handleKeyUp(event.key.keysym.sym, *scene);
|
handleKeyUp(event.key.keysym.sym, *scene);
|
||||||
} else {
|
} else {
|
||||||
if (event.key.keysym.sym == SDLK_ESCAPE ||
|
if ( event.key.keysym.sym == SDLK_ESCAPE || event.key.keysym.sym == SDLK_RETURN ) {
|
||||||
event.key.keysym.sym == SDLK_RETURN) {
|
|
||||||
SDL_StopTextInput();
|
SDL_StopTextInput();
|
||||||
unsetFlag(TEXT_INPUT_FLAG);
|
unsetFlag(TEXT_INPUT_FLAG);
|
||||||
}
|
}
|
||||||
@ -814,16 +790,13 @@ void pollEvents(std::shared_ptr<SDLPP::Scene> &scene) {
|
|||||||
break;
|
break;
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
if(getFlag(TEXT_INPUT_FLAG)) {
|
if(getFlag(TEXT_INPUT_FLAG)) {
|
||||||
if (event.key.keysym.sym == SDLK_BACKSPACE &&
|
if( event.key.keysym.sym == SDLK_BACKSPACE && !global_test_text_text.empty() ) {
|
||||||
!global_test_text_text.empty()) {
|
|
||||||
global_test_text_text.pop_back();
|
global_test_text_text.pop_back();
|
||||||
setFlag(TEXT_UPDATE_FLAG);
|
setFlag(TEXT_UPDATE_FLAG);
|
||||||
} else if (event.key.keysym.sym == SDLK_c &&
|
} else if( event.key.keysym.sym == SDLK_c && SDL_GetModState() & KMOD_CTRL ) {
|
||||||
SDL_GetModState() & KMOD_CTRL) {
|
|
||||||
// handle copy
|
// handle copy
|
||||||
SDL_SetClipboardText( global_test_text_text.c_str() );
|
SDL_SetClipboardText( global_test_text_text.c_str() );
|
||||||
} else if (event.key.keysym.sym == SDLK_v &&
|
} else if( event.key.keysym.sym == SDLK_v && SDL_GetModState() & KMOD_CTRL ) {
|
||||||
SDL_GetModState() & KMOD_CTRL) {
|
|
||||||
// handle paste
|
// handle paste
|
||||||
global_test_text_text += SDL_GetClipboardText();
|
global_test_text_text += SDL_GetClipboardText();
|
||||||
setFlag(TEXT_UPDATE_FLAG);
|
setFlag(TEXT_UPDATE_FLAG);
|
||||||
@ -1030,8 +1003,7 @@ void testButtonFunc(void * /*UNUSED*/, Button * /*UNUSED*/) {
|
|||||||
SDL_StartTextInput();
|
SDL_StartTextInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
void openMapEditor(std::shared_ptr<SDLPP::Scene> &scene,
|
void openMapEditor(std::shared_ptr<SDLPP::Scene> &scene, const std::string &filename) {
|
||||||
const std::string &filename) {
|
|
||||||
auto renderer = scene->getRendererShared();
|
auto renderer = scene->getRendererShared();
|
||||||
auto font = std::make_shared<SDLPP::Font>("testfont.ttf", 36);
|
auto font = std::make_shared<SDLPP::Font>("testfont.ttf", 36);
|
||||||
auto font_config = std::make_shared<SDLPP::FontConfiguration>(
|
auto font_config = std::make_shared<SDLPP::FontConfiguration>(
|
||||||
@ -1047,8 +1019,8 @@ void openMapEditor(std::shared_ptr<SDLPP::Scene> &scene,
|
|||||||
if(filename.empty()) {
|
if(filename.empty()) {
|
||||||
loadEmptyMap(global_vars.objects, MAP_WIDTH);
|
loadEmptyMap(global_vars.objects, MAP_WIDTH);
|
||||||
} else {
|
} else {
|
||||||
loadMap(scene, global_vars.mario, "test_binary.bin",
|
loadMap(scene, global_vars.mario, "test_binary.bin", global_vars.objects,
|
||||||
global_vars.objects, true, MAP_WIDTH);
|
true, MAP_WIDTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
// map
|
// map
|
||||||
@ -1092,17 +1064,15 @@ void openMapEditor(std::shared_ptr<SDLPP::Scene> &scene,
|
|||||||
2, scene);
|
2, scene);
|
||||||
|
|
||||||
global_test_text = std::make_shared<SDLPP::TextRenderer>(
|
global_test_text = std::make_shared<SDLPP::TextRenderer>(
|
||||||
0.3, 0.05, BLOCK_SIZE * 4, BLOCK_SIZE * 2, renderer, "TEST TEXT",
|
0.3, 0.05, BLOCK_SIZE*4, BLOCK_SIZE*2,
|
||||||
font_config, SDLPP_TEXT_CENTER);
|
renderer, "TEST TEXT", font_config, SDLPP_TEXT_CENTER);
|
||||||
global_test_text->setAlignment(SDLPP::OBJ_CENTER, SDLPP::OBJ_CENTER);
|
global_test_text->setAlignment(SDLPP::OBJ_CENTER, SDLPP::OBJ_CENTER);
|
||||||
global_test_text->setPermanent();
|
global_test_text->setPermanent();
|
||||||
scene->addObject(global_test_text);
|
scene->addObject(global_test_text);
|
||||||
|
|
||||||
global_vars.map.max_page = global_vars.objects.size() - MAP_WIDTH;
|
global_vars.map.max_page = global_vars.objects.size() - MAP_WIDTH;
|
||||||
// arrowInputs[1] - rightMapInput, arrowInputs[0] - leftMapInput
|
// arrowInputs[1] - rightMapInput, arrowInputs[0] - leftMapInput
|
||||||
toolMoveUpdateButtons(
|
toolMoveUpdateButtons(arrowInputs[1].other_button.get(), arrowInputs[0].other_button.get(), global_vars.map.cur_page, global_vars.map.max_page, true);
|
||||||
arrowInputs[1].other_button.get(), arrowInputs[0].other_button.get(),
|
|
||||||
global_vars.map.cur_page, global_vars.map.max_page, true);
|
|
||||||
|
|
||||||
auto mouse =
|
auto mouse =
|
||||||
std::make_shared<SDLPP::RectangleRender>(0.01, 0.01, 0, 0, renderer);
|
std::make_shared<SDLPP::RectangleRender>(0.01, 0.01, 0, 0, renderer);
|
||||||
@ -1159,8 +1129,7 @@ void openMapEditor(std::shared_ptr<SDLPP::Scene> &scene,
|
|||||||
global_vars.tool.cur_page_characters = 0;
|
global_vars.tool.cur_page_characters = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<SDLPP::Scene>
|
std::shared_ptr<SDLPP::Scene> createEditorMainScene(std::shared_ptr<SDLPP::Renderer> &renderer) {
|
||||||
createEditorMainScene(std::shared_ptr<SDLPP::Renderer> &renderer) {
|
|
||||||
auto scene = std::make_shared<SDLPP::Scene>(renderer);
|
auto scene = std::make_shared<SDLPP::Scene>(renderer);
|
||||||
|
|
||||||
global_vars.tool.max_page_tools =
|
global_vars.tool.max_page_tools =
|
||||||
@ -1191,8 +1160,7 @@ createEditorMainScene(std::shared_ptr<SDLPP::Renderer> &renderer) {
|
|||||||
global_vars.buttons.emplace_back(std::make_shared<Button>(
|
global_vars.buttons.emplace_back(std::make_shared<Button>(
|
||||||
0, 1 - MAP_HEIGHT * BLOCK_SIZE, BLOCK_SIZE, MAP_HEIGHT * BLOCK_SIZE,
|
0, 1 - MAP_HEIGHT * BLOCK_SIZE, BLOCK_SIZE, MAP_HEIGHT * BLOCK_SIZE,
|
||||||
renderer, "<", default_button_theme, moveMapLeft, &left_map_input));
|
renderer, "<", default_button_theme, moveMapLeft, &left_map_input));
|
||||||
global_vars.buttons.back()->setAlignment(SDLPP::OBJ_CENTER,
|
global_vars.buttons.back()->setAlignment(SDLPP::OBJ_CENTER, SDLPP::OBJ_CENTER);
|
||||||
SDLPP::OBJ_CENTER);
|
|
||||||
global_vars.buttons.back()->setPermanent();
|
global_vars.buttons.back()->setPermanent();
|
||||||
global_vars.buttons.back()->setButtonIndex(global_vars.buttons.size() - 1);
|
global_vars.buttons.back()->setButtonIndex(global_vars.buttons.size() - 1);
|
||||||
// right map arrow
|
// right map arrow
|
||||||
@ -1200,29 +1168,23 @@ createEditorMainScene(std::shared_ptr<SDLPP::Renderer> &renderer) {
|
|||||||
right_map_input.scene = scene;
|
right_map_input.scene = scene;
|
||||||
right_map_input.other_button = global_vars.buttons.back();
|
right_map_input.other_button = global_vars.buttons.back();
|
||||||
global_vars.buttons.emplace_back(std::make_shared<Button>(
|
global_vars.buttons.emplace_back(std::make_shared<Button>(
|
||||||
(MAP_WIDTH + 1) * BLOCK_SIZE, 1 - MAP_HEIGHT * BLOCK_SIZE, BLOCK_SIZE,
|
(MAP_WIDTH + 1) * BLOCK_SIZE, 1 - MAP_HEIGHT * BLOCK_SIZE, BLOCK_SIZE, MAP_HEIGHT * BLOCK_SIZE,
|
||||||
MAP_HEIGHT * BLOCK_SIZE, renderer, ">", default_button_theme,
|
renderer, ">", default_button_theme, moveMapRight, &right_map_input));
|
||||||
moveMapRight, &right_map_input));
|
global_vars.buttons.back()->setAlignment(SDLPP::OBJ_CENTER, SDLPP::OBJ_CENTER);
|
||||||
global_vars.buttons.back()->setAlignment(SDLPP::OBJ_CENTER,
|
|
||||||
SDLPP::OBJ_CENTER);
|
|
||||||
global_vars.buttons.back()->setPermanent();
|
global_vars.buttons.back()->setPermanent();
|
||||||
global_vars.buttons.back()->setButtonIndex(global_vars.buttons.size() - 1);
|
global_vars.buttons.back()->setButtonIndex(global_vars.buttons.size() - 1);
|
||||||
left_map_input.other_button = global_vars.buttons.back();
|
left_map_input.other_button = global_vars.buttons.back();
|
||||||
// ensure disabled/enabled properly
|
// ensure disabled/enabled properly
|
||||||
toolMoveUpdateButtons(
|
toolMoveUpdateButtons(right_map_input.other_button.get(), global_vars.buttons.back().get(), global_vars.map.cur_page, global_vars.map.max_page, true);
|
||||||
right_map_input.other_button.get(), global_vars.buttons.back().get(),
|
|
||||||
global_vars.map.cur_page, global_vars.map.max_page, true);
|
|
||||||
|
|
||||||
// left tool arrow
|
// left tool arrow
|
||||||
auto &left_tool_input = arrowInputs[2];
|
auto &left_tool_input = arrowInputs[2];
|
||||||
left_tool_input.scene = scene;
|
left_tool_input.scene = scene;
|
||||||
left_tool_input.other_button = nullptr;
|
left_tool_input.other_button = nullptr;
|
||||||
global_vars.buttons.emplace_back(std::make_shared<Button>(
|
global_vars.buttons.emplace_back(std::make_shared<Button>(
|
||||||
(MAP_WIDTH - TOOLS_WIDTH - 1) * BLOCK_SIZE,
|
(MAP_WIDTH - TOOLS_WIDTH - 1) * BLOCK_SIZE, 1 - (MAP_HEIGHT + 3) * BLOCK_SIZE, BLOCK_SIZE, 2 * BLOCK_SIZE,
|
||||||
1 - (MAP_HEIGHT + 3) * BLOCK_SIZE, BLOCK_SIZE, 2 * BLOCK_SIZE, renderer,
|
renderer, "<", default_button_theme, moveToolsLeftButton, &left_tool_input));
|
||||||
"<", default_button_theme, moveToolsLeftButton, &left_tool_input));
|
global_vars.buttons.back()->setAlignment(SDLPP::OBJ_CENTER, SDLPP::OBJ_CENTER);
|
||||||
global_vars.buttons.back()->setAlignment(SDLPP::OBJ_CENTER,
|
|
||||||
SDLPP::OBJ_CENTER);
|
|
||||||
global_vars.buttons.back()->setPermanent();
|
global_vars.buttons.back()->setPermanent();
|
||||||
global_vars.buttons.back()->setButtonIndex(global_vars.buttons.size() - 1);
|
global_vars.buttons.back()->setButtonIndex(global_vars.buttons.size() - 1);
|
||||||
global_vars.tool.button_left_tools = global_vars.buttons.back();
|
global_vars.tool.button_left_tools = global_vars.buttons.back();
|
||||||
@ -1231,31 +1193,24 @@ createEditorMainScene(std::shared_ptr<SDLPP::Renderer> &renderer) {
|
|||||||
right_tool_input.scene = scene;
|
right_tool_input.scene = scene;
|
||||||
right_tool_input.other_button = global_vars.buttons.back();
|
right_tool_input.other_button = global_vars.buttons.back();
|
||||||
global_vars.buttons.emplace_back(std::make_shared<Button>(
|
global_vars.buttons.emplace_back(std::make_shared<Button>(
|
||||||
MAP_WIDTH * BLOCK_SIZE, 1 - (MAP_HEIGHT + 3) * BLOCK_SIZE, BLOCK_SIZE,
|
MAP_WIDTH * BLOCK_SIZE, 1 - (MAP_HEIGHT + 3) * BLOCK_SIZE, BLOCK_SIZE, 2 * BLOCK_SIZE,
|
||||||
2 * BLOCK_SIZE, renderer, ">", default_button_theme,
|
renderer, ">", default_button_theme, moveToolsRightButton, &right_tool_input));
|
||||||
moveToolsRightButton, &right_tool_input));
|
global_vars.buttons.back()->setAlignment(SDLPP::OBJ_CENTER, SDLPP::OBJ_CENTER);
|
||||||
global_vars.buttons.back()->setAlignment(SDLPP::OBJ_CENTER,
|
|
||||||
SDLPP::OBJ_CENTER);
|
|
||||||
global_vars.buttons.back()->setPermanent();
|
global_vars.buttons.back()->setPermanent();
|
||||||
global_vars.buttons.back()->setButtonIndex(global_vars.buttons.size() - 1);
|
global_vars.buttons.back()->setButtonIndex(global_vars.buttons.size() - 1);
|
||||||
left_tool_input.other_button = global_vars.buttons.back();
|
left_tool_input.other_button = global_vars.buttons.back();
|
||||||
global_vars.tool.button_right_tools = global_vars.buttons.back();
|
global_vars.tool.button_right_tools = global_vars.buttons.back();
|
||||||
// ensure disabled/enabled properly
|
// ensure disabled/enabled properly
|
||||||
toolMoveUpdateButtons(right_tool_input.other_button.get(),
|
toolMoveUpdateButtons(right_tool_input.other_button.get(), global_vars.buttons.back().get(), global_vars.tool.cur_page_tools, global_vars.tool.max_page_tools, false);
|
||||||
global_vars.buttons.back().get(),
|
|
||||||
global_vars.tool.cur_page_tools,
|
|
||||||
global_vars.tool.max_page_tools, false);
|
|
||||||
|
|
||||||
// left mod arrow
|
// left mod arrow
|
||||||
auto &left_mod_input = arrowInputs[4];
|
auto &left_mod_input = arrowInputs[4];
|
||||||
left_mod_input.scene = scene;
|
left_mod_input.scene = scene;
|
||||||
left_mod_input.other_button = nullptr;
|
left_mod_input.other_button = nullptr;
|
||||||
global_vars.buttons.emplace_back(std::make_shared<Button>(
|
global_vars.buttons.emplace_back(std::make_shared<Button>(
|
||||||
4 * BLOCK_SIZE, 1 - (MAP_HEIGHT + 3) * BLOCK_SIZE, BLOCK_SIZE,
|
4 * BLOCK_SIZE, 1 - (MAP_HEIGHT + 3) * BLOCK_SIZE, BLOCK_SIZE, 2 * BLOCK_SIZE,
|
||||||
2 * BLOCK_SIZE, renderer, "<", default_button_theme, moveModsLeft,
|
renderer, "<", default_button_theme, moveModsLeft, &left_mod_input));
|
||||||
&left_mod_input));
|
global_vars.buttons.back()->setAlignment(SDLPP::OBJ_CENTER, SDLPP::OBJ_CENTER);
|
||||||
global_vars.buttons.back()->setAlignment(SDLPP::OBJ_CENTER,
|
|
||||||
SDLPP::OBJ_CENTER);
|
|
||||||
global_vars.buttons.back()->setPermanent();
|
global_vars.buttons.back()->setPermanent();
|
||||||
global_vars.buttons.back()->setButtonIndex(global_vars.buttons.size() - 1);
|
global_vars.buttons.back()->setButtonIndex(global_vars.buttons.size() - 1);
|
||||||
global_vars.tool.button_left_mods = global_vars.buttons.back();
|
global_vars.tool.button_left_mods = global_vars.buttons.back();
|
||||||
@ -1264,30 +1219,24 @@ createEditorMainScene(std::shared_ptr<SDLPP::Renderer> &renderer) {
|
|||||||
right_mod_input.scene = scene;
|
right_mod_input.scene = scene;
|
||||||
right_mod_input.other_button = global_vars.buttons.back();
|
right_mod_input.other_button = global_vars.buttons.back();
|
||||||
global_vars.buttons.emplace_back(std::make_shared<Button>(
|
global_vars.buttons.emplace_back(std::make_shared<Button>(
|
||||||
(MOD_WIDTH + 5) * BLOCK_SIZE, 1 - (MAP_HEIGHT + 3) * BLOCK_SIZE,
|
(MOD_WIDTH + 5) * BLOCK_SIZE, 1 - (MAP_HEIGHT + 3) * BLOCK_SIZE, BLOCK_SIZE, 2 * BLOCK_SIZE,
|
||||||
BLOCK_SIZE, 2 * BLOCK_SIZE, renderer, ">", default_button_theme,
|
renderer, ">", default_button_theme, moveModsRight, &right_mod_input));
|
||||||
moveModsRight, &right_mod_input));
|
global_vars.buttons.back()->setAlignment(SDLPP::OBJ_CENTER, SDLPP::OBJ_CENTER);
|
||||||
global_vars.buttons.back()->setAlignment(SDLPP::OBJ_CENTER,
|
|
||||||
SDLPP::OBJ_CENTER);
|
|
||||||
global_vars.buttons.back()->setPermanent();
|
global_vars.buttons.back()->setPermanent();
|
||||||
global_vars.buttons.back()->setButtonIndex(global_vars.buttons.size() - 1);
|
global_vars.buttons.back()->setButtonIndex(global_vars.buttons.size() - 1);
|
||||||
left_mod_input.other_button = global_vars.buttons.back();
|
left_mod_input.other_button = global_vars.buttons.back();
|
||||||
global_vars.tool.button_right_mods = global_vars.buttons.back();
|
global_vars.tool.button_right_mods = global_vars.buttons.back();
|
||||||
// ensure disabled/enabled properly
|
// ensure disabled/enabled properly
|
||||||
toolMoveUpdateButtons(
|
toolMoveUpdateButtons(right_mod_input.other_button.get(), global_vars.buttons.back().get(), global_vars.tool.cur_page_mods, global_vars.tool.max_page_mods, false);
|
||||||
right_mod_input.other_button.get(), global_vars.buttons.back().get(),
|
|
||||||
global_vars.tool.cur_page_mods, global_vars.tool.max_page_mods, false);
|
|
||||||
|
|
||||||
// left character arrow
|
// left character arrow
|
||||||
auto &left_character_input = arrowInputs[6];
|
auto &left_character_input = arrowInputs[6];
|
||||||
left_character_input.scene = scene;
|
left_character_input.scene = scene;
|
||||||
left_character_input.other_button = nullptr;
|
left_character_input.other_button = nullptr;
|
||||||
global_vars.buttons.emplace_back(std::make_shared<Button>(
|
global_vars.buttons.emplace_back(std::make_shared<Button>(
|
||||||
(MOD_WIDTH + 7) * BLOCK_SIZE, 1 - (MAP_HEIGHT + 3) * BLOCK_SIZE,
|
(MOD_WIDTH + 7) * BLOCK_SIZE, 1 - (MAP_HEIGHT + 3) * BLOCK_SIZE, BLOCK_SIZE, 2 * BLOCK_SIZE,
|
||||||
BLOCK_SIZE, 2 * BLOCK_SIZE, renderer, "<", default_button_theme,
|
renderer, "<", default_button_theme, moveCharsLeft, &left_character_input));
|
||||||
moveCharsLeft, &left_character_input));
|
global_vars.buttons.back()->setAlignment(SDLPP::OBJ_CENTER, SDLPP::OBJ_CENTER);
|
||||||
global_vars.buttons.back()->setAlignment(SDLPP::OBJ_CENTER,
|
|
||||||
SDLPP::OBJ_CENTER);
|
|
||||||
global_vars.buttons.back()->setPermanent();
|
global_vars.buttons.back()->setPermanent();
|
||||||
global_vars.buttons.back()->setButtonIndex(global_vars.buttons.size() - 1);
|
global_vars.buttons.back()->setButtonIndex(global_vars.buttons.size() - 1);
|
||||||
global_vars.tool.button_left_characters = global_vars.buttons.back();
|
global_vars.tool.button_left_characters = global_vars.buttons.back();
|
||||||
@ -1296,24 +1245,17 @@ createEditorMainScene(std::shared_ptr<SDLPP::Renderer> &renderer) {
|
|||||||
right_character_input.scene = scene;
|
right_character_input.scene = scene;
|
||||||
right_character_input.other_button = global_vars.buttons.back();
|
right_character_input.other_button = global_vars.buttons.back();
|
||||||
global_vars.buttons.emplace_back(std::make_shared<Button>(
|
global_vars.buttons.emplace_back(std::make_shared<Button>(
|
||||||
(MOD_WIDTH + 8 + CHARACTER_WIDTH) * BLOCK_SIZE,
|
(MOD_WIDTH + 8 + CHARACTER_WIDTH) * BLOCK_SIZE, 1 - (MAP_HEIGHT + 3) * BLOCK_SIZE, BLOCK_SIZE, 2 * BLOCK_SIZE,
|
||||||
1 - (MAP_HEIGHT + 3) * BLOCK_SIZE, BLOCK_SIZE, 2 * BLOCK_SIZE, renderer,
|
renderer, ">", default_button_theme, moveCharsRight, &right_character_input));
|
||||||
">", default_button_theme, moveCharsRight, &right_character_input));
|
global_vars.buttons.back()->setAlignment(SDLPP::OBJ_CENTER, SDLPP::OBJ_CENTER);
|
||||||
global_vars.buttons.back()->setAlignment(SDLPP::OBJ_CENTER,
|
|
||||||
SDLPP::OBJ_CENTER);
|
|
||||||
global_vars.buttons.back()->setPermanent();
|
global_vars.buttons.back()->setPermanent();
|
||||||
global_vars.buttons.back()->setButtonIndex(global_vars.buttons.size() - 1);
|
global_vars.buttons.back()->setButtonIndex(global_vars.buttons.size() - 1);
|
||||||
global_vars.tool.button_right_characters = global_vars.buttons.back();
|
global_vars.tool.button_right_characters = global_vars.buttons.back();
|
||||||
// ensure disabled/enabled properly
|
// ensure disabled/enabled properly
|
||||||
toolMoveUpdateButtons(right_character_input.other_button.get(),
|
toolMoveUpdateButtons(right_character_input.other_button.get(), global_vars.buttons.back().get(), global_vars.tool.cur_page_characters, global_vars.tool.max_page_characters, false);
|
||||||
global_vars.buttons.back().get(),
|
|
||||||
global_vars.tool.cur_page_characters,
|
|
||||||
global_vars.tool.max_page_characters, false);
|
|
||||||
left_character_input.other_button = global_vars.buttons.back();
|
left_character_input.other_button = global_vars.buttons.back();
|
||||||
|
|
||||||
global_vars.buttons.emplace_back(std::make_shared<Button>(
|
global_vars.buttons.emplace_back(std::make_shared<Button>(0, 0, 0.2, 0.2, renderer, "Write Button", default_button_theme, testButtonFunc, nullptr));
|
||||||
0, 0, 0.2, 0.2, renderer, "Write Button", default_button_theme,
|
|
||||||
testButtonFunc, nullptr));
|
|
||||||
global_vars.buttons.back()->setPermanent();
|
global_vars.buttons.back()->setPermanent();
|
||||||
global_vars.buttons.back()->setButtonIndex(global_vars.buttons.size() - 1);
|
global_vars.buttons.back()->setButtonIndex(global_vars.buttons.size() - 1);
|
||||||
|
|
||||||
|
@ -50,11 +50,10 @@ void handleKeyUpMainMenu(SDL_Keycode key, SDLPP::Scene & /*UNUSED*/) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<SDLPP::Scene>
|
std::shared_ptr<SDLPP::Scene> createSceneMainMenu(std::shared_ptr<SDLPP::Renderer> &renderer) {
|
||||||
createSceneMainMenu(std::shared_ptr<SDLPP::Renderer> &renderer) {
|
|
||||||
auto scene = std::make_shared<SDLPP::Scene>(renderer);
|
auto scene = std::make_shared<SDLPP::Scene>(renderer);
|
||||||
auto bg = std::make_shared<SDLPP::RectangleRender>(0, 0, 10, 10, renderer,
|
auto bg = std::make_shared<SDLPP::RectangleRender>(
|
||||||
"#00000088", true);
|
0, 0, 10, 10, renderer, "#00000088", true);
|
||||||
bg->setPermanent();
|
bg->setPermanent();
|
||||||
bg->setId(1);
|
bg->setId(1);
|
||||||
scene->addObject(bg);
|
scene->addObject(bg);
|
||||||
@ -81,31 +80,27 @@ createSceneMainMenu(std::shared_ptr<SDLPP::Renderer> &renderer) {
|
|||||||
default_button_theme.outline = 0.1;
|
default_button_theme.outline = 0.1;
|
||||||
// buttons
|
// buttons
|
||||||
__buttons_main_menu.emplace_back(std::make_shared<Button>(
|
__buttons_main_menu.emplace_back(std::make_shared<Button>(
|
||||||
0.2, 0.25, 0.6, 0.1, renderer, "SAVE", default_button_theme,
|
0.2, 0.25, 0.6, 0.1,
|
||||||
saveMapCallback, nullptr));
|
renderer, "SAVE", default_button_theme, saveMapCallback, nullptr));
|
||||||
__buttons_main_menu.back()->setAlignment(SDLPP::OBJ_CENTER,
|
__buttons_main_menu.back()->setAlignment(SDLPP::OBJ_CENTER, SDLPP::OBJ_CENTER);
|
||||||
SDLPP::OBJ_CENTER);
|
|
||||||
__buttons_main_menu.back()->setPermanent();
|
__buttons_main_menu.back()->setPermanent();
|
||||||
__buttons_main_menu.back()->setButtonIndex(__buttons_main_menu.size() - 1);
|
__buttons_main_menu.back()->setButtonIndex(__buttons_main_menu.size() - 1);
|
||||||
__buttons_main_menu.emplace_back(std::make_shared<Button>(
|
__buttons_main_menu.emplace_back(std::make_shared<Button>(
|
||||||
0.2, 0.4, 0.6, 0.1, renderer, "LOAD", default_button_theme,
|
0.2, 0.4, 0.6, 0.1,
|
||||||
loadMapDialogCallback, nullptr));
|
renderer, "LOAD", default_button_theme, loadMapDialogCallback, nullptr));
|
||||||
__buttons_main_menu.back()->setAlignment(SDLPP::OBJ_CENTER,
|
__buttons_main_menu.back()->setAlignment(SDLPP::OBJ_CENTER, SDLPP::OBJ_CENTER);
|
||||||
SDLPP::OBJ_CENTER);
|
|
||||||
__buttons_main_menu.back()->setPermanent();
|
__buttons_main_menu.back()->setPermanent();
|
||||||
__buttons_main_menu.back()->setButtonIndex(__buttons_main_menu.size() - 1);
|
__buttons_main_menu.back()->setButtonIndex(__buttons_main_menu.size() - 1);
|
||||||
__buttons_main_menu.emplace_back(std::make_shared<Button>(
|
__buttons_main_menu.emplace_back(std::make_shared<Button>(
|
||||||
0.2, 0.55, 0.6, 0.1, renderer, "RESUME", default_button_theme,
|
0.2, 0.55, 0.6, 0.1,
|
||||||
resumeMainMenuCallback, nullptr));
|
renderer, "RESUME", default_button_theme, resumeMainMenuCallback, nullptr));
|
||||||
__buttons_main_menu.back()->setAlignment(SDLPP::OBJ_CENTER,
|
__buttons_main_menu.back()->setAlignment(SDLPP::OBJ_CENTER, SDLPP::OBJ_CENTER);
|
||||||
SDLPP::OBJ_CENTER);
|
|
||||||
__buttons_main_menu.back()->setPermanent();
|
__buttons_main_menu.back()->setPermanent();
|
||||||
__buttons_main_menu.back()->setButtonIndex(__buttons_main_menu.size() - 1);
|
__buttons_main_menu.back()->setButtonIndex(__buttons_main_menu.size() - 1);
|
||||||
__buttons_main_menu.emplace_back(std::make_shared<Button>(
|
__buttons_main_menu.emplace_back(std::make_shared<Button>(
|
||||||
0.2, 0.7, 0.6, 0.1, renderer, "QUIT", default_button_theme,
|
0.2, 0.7, 0.6, 0.1,
|
||||||
quitMainMenuCallback, nullptr));
|
renderer, "QUIT", default_button_theme, quitMainMenuCallback, nullptr));
|
||||||
__buttons_main_menu.back()->setAlignment(SDLPP::OBJ_CENTER,
|
__buttons_main_menu.back()->setAlignment(SDLPP::OBJ_CENTER, SDLPP::OBJ_CENTER);
|
||||||
SDLPP::OBJ_CENTER);
|
|
||||||
__buttons_main_menu.back()->setPermanent();
|
__buttons_main_menu.back()->setPermanent();
|
||||||
__buttons_main_menu.back()->setButtonIndex(__buttons_main_menu.size() - 1);
|
__buttons_main_menu.back()->setButtonIndex(__buttons_main_menu.size() - 1);
|
||||||
for(auto &button : __buttons_main_menu) {
|
for(auto &button : __buttons_main_menu) {
|
||||||
@ -169,11 +164,9 @@ void pollEventsMainMenu(std::shared_ptr<SDLPP::Scene> &scene) {
|
|||||||
getMousePositionFlagsMainMenu(*scene);
|
getMousePositionFlagsMainMenu(*scene);
|
||||||
break;
|
break;
|
||||||
case SDL_MOUSEBUTTONUP:
|
case SDL_MOUSEBUTTONUP:
|
||||||
if (__cur_button_index_main_menu_down ==
|
if (__cur_button_index_main_menu_down == __cur_button_index_main_menu &&
|
||||||
__cur_button_index_main_menu &&
|
|
||||||
__cur_button_index_main_menu != (uint64_t)-1) {
|
__cur_button_index_main_menu != (uint64_t)-1) {
|
||||||
__buttons_main_menu[__cur_button_index_main_menu]
|
__buttons_main_menu[__cur_button_index_main_menu]->performFunction();
|
||||||
->performFunction();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_MOUSEBUTTONDOWN:
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
@ -186,8 +179,7 @@ void pollEventsMainMenu(std::shared_ptr<SDLPP::Scene> &scene) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStruct
|
SceneStruct createEditorMainMenuScene(std::shared_ptr<SDLPP::Renderer> &renderer) {
|
||||||
createEditorMainMenuScene(std::shared_ptr<SDLPP::Renderer> &renderer) {
|
|
||||||
SceneStruct ret{};
|
SceneStruct ret{};
|
||||||
ret.scene = createSceneMainMenu(renderer);
|
ret.scene = createSceneMainMenu(renderer);
|
||||||
ret.additionalRender = additionalRenderMainMenu;
|
ret.additionalRender = additionalRenderMainMenu;
|
||||||
|
@ -18,9 +18,7 @@ void saveMapCallback(void *input, Button *caller);
|
|||||||
void loadMapDialogCallback(void *input, Button *caller);
|
void loadMapDialogCallback(void *input, Button *caller);
|
||||||
|
|
||||||
SceneStruct createEditorScene(std::shared_ptr<SDLPP::Renderer> &renderer);
|
SceneStruct createEditorScene(std::shared_ptr<SDLPP::Renderer> &renderer);
|
||||||
SceneStruct
|
SceneStruct createEditorMainMenuScene(std::shared_ptr<SDLPP::Renderer> &renderer);
|
||||||
createEditorMainMenuScene(std::shared_ptr<SDLPP::Renderer> &renderer);
|
SceneStruct createEditorFileChoiceScene(std::shared_ptr<SDLPP::Renderer> &renderer);
|
||||||
SceneStruct
|
|
||||||
createEditorFileChoiceScene(std::shared_ptr<SDLPP::Renderer> &renderer);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
20
mario/testmap.txt
Normal file
20
mario/testmap.txt
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
35
|
||||||
|
16
|
||||||
|
15
|
||||||
|
13
|
||||||
|
F
|
||||||
|
F
|
||||||
|
F zxc
|
||||||
|
F asd
|
||||||
|
F
|
||||||
|
F
|
||||||
|
F
|
||||||
|
F
|
||||||
|
F
|
||||||
|
F
|
||||||
|
F
|
||||||
|
F T
|
||||||
|
F IRD
|
||||||
|
F IRGLD qwwwr
|
||||||
|
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
|
||||||
|
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
|
Loading…
Reference in New Issue
Block a user