Mario Editor: save to filename entered in editor
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
c505915fd2
commit
70f30b6767
@ -94,7 +94,8 @@ int main() {
|
|||||||
SDL_framerateDelay(&gFPS);
|
SDL_framerateDelay(&gFPS);
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
std::lock_guard<std::mutex> lock(render_mutex);
|
std::lock_guard<std::mutex> lock(render_mutex);
|
||||||
for (size_t i = 0; i < game_scenes.size(); i++) {
|
auto max_game_scenes = game_scenes.size();
|
||||||
|
for (size_t i = 0; i < max_game_scenes; i++) {
|
||||||
game_scenes[i].additionalRender(game_scenes[i].scene);
|
game_scenes[i].additionalRender(game_scenes[i].scene);
|
||||||
// additional renderer can remove scene from game_scenes, better
|
// additional renderer can remove scene from game_scenes, better
|
||||||
// check
|
// check
|
||||||
|
@ -142,16 +142,12 @@ bool getFlag(uint64_t flag) {
|
|||||||
|
|
||||||
void saveMapCallback(void * /*UNUSED*/, Button * /*UNUSED*/) {
|
void saveMapCallback(void * /*UNUSED*/, Button * /*UNUSED*/) {
|
||||||
std::cout << "SAVING" << std::endl;
|
std::cout << "SAVING" << std::endl;
|
||||||
// TODO filename
|
saveMap("levels/" + level_name_text + ".marmap", global_vars.objects);
|
||||||
saveMap("test_binary2.bin", global_vars.objects);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadMapDialogCallback(void * /*UNUSED*/, Button * /*UNUSED*/) {
|
void loadMapDialogCallback(void * /*UNUSED*/, Button * /*UNUSED*/) {
|
||||||
std::cout << "LOADING" << std::endl;
|
std::cout << "LOADING" << std::endl;
|
||||||
setFlag(LOAD_MAP_FLAG);
|
setFlag(LOAD_MAP_FLAG);
|
||||||
// TODO filename
|
|
||||||
/* editorScene->resetScene();
|
|
||||||
openMapEditor(editorScene, "test_binary.bin");*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateTool() {
|
void updateTool() {
|
||||||
@ -1027,27 +1023,6 @@ void populateWorldType(
|
|||||||
scene->addObject(tool_text);
|
scene->addObject(tool_text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dialogFinishedTest(bool result) {
|
|
||||||
level_name_text = result ? "YEAH, BOI!" : "Nah, boi";
|
|
||||||
setFlag(TEXT_UPDATE_FLAG);
|
|
||||||
}
|
|
||||||
|
|
||||||
void okDialogFinalizer() {
|
|
||||||
level_name_text = "You OK'd";
|
|
||||||
setFlag(TEXT_UPDATE_FLAG);
|
|
||||||
}
|
|
||||||
|
|
||||||
void testButtonFunc(void * /*UNUSED*/, Button * /*UNUSED*/) {
|
|
||||||
/* game_scenes.push_back(
|
|
||||||
createYesNoScene(game_scenes.back().scene->getRendererShared(),
|
|
||||||
"Yeah?", dialogFinishedTest));*/
|
|
||||||
game_scenes.push_back(createOkScene(
|
|
||||||
game_scenes.back().scene->getRendererShared(),
|
|
||||||
"You cannot choose anything other than OK", okDialogFinalizer));
|
|
||||||
/* setFlag(TEXT_INPUT_FLAG);
|
|
||||||
SDL_StartTextInput();*/
|
|
||||||
}
|
|
||||||
|
|
||||||
void enableTextInput(void */*UNUSED*/, Button */*UNUSED*/) {
|
void enableTextInput(void */*UNUSED*/, Button */*UNUSED*/) {
|
||||||
setFlag(TEXT_INPUT_FLAG);
|
setFlag(TEXT_INPUT_FLAG);
|
||||||
SDL_StartTextInput();
|
SDL_StartTextInput();
|
||||||
@ -1169,6 +1144,13 @@ void openMapEditor(std::shared_ptr<SDLPP::Scene> &scene,
|
|||||||
scene->addObject(button);
|
scene->addObject(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// level_name label
|
||||||
|
auto level_name_label = std::make_shared<SDLPP::TextRenderer>(
|
||||||
|
0.1, 0.1, BLOCK_SIZE * 8, 0.05, renderer, "Level Name:", font_config, SDLPP_TEXT_LEFT);
|
||||||
|
level_name_label->setAlignment(SDLPP::OBJ_CENTER, SDLPP::OBJ_CENTER);
|
||||||
|
level_name_label->setPermanent();
|
||||||
|
scene->addObject(level_name_label);
|
||||||
|
|
||||||
setFlag(UPDATE_FLAG);
|
setFlag(UPDATE_FLAG);
|
||||||
global_vars.tool.cur_page_tools = 0;
|
global_vars.tool.cur_page_tools = 0;
|
||||||
global_vars.tool.cur_page_mods = 0;
|
global_vars.tool.cur_page_mods = 0;
|
||||||
@ -1329,7 +1311,7 @@ createEditorMainScene(std::shared_ptr<SDLPP::Renderer> &renderer) {
|
|||||||
|
|
||||||
// level name
|
// level name
|
||||||
level_name_object = std::make_shared<Button>(
|
level_name_object = std::make_shared<Button>(
|
||||||
0.1, 0.05, BLOCK_SIZE * 16, BLOCK_SIZE * 2, renderer, level_name_text,
|
0.1, 0.15, BLOCK_SIZE * 16, BLOCK_SIZE * 2, renderer, level_name_text,
|
||||||
default_button_theme, enableTextInput, nullptr);
|
default_button_theme, enableTextInput, nullptr);
|
||||||
level_name_object->setAlignment(SDLPP::OBJ_CENTER, SDLPP::OBJ_CENTER);
|
level_name_object->setAlignment(SDLPP::OBJ_CENTER, SDLPP::OBJ_CENTER);
|
||||||
level_name_object->setPermanent();
|
level_name_object->setPermanent();
|
||||||
|
Loading…
Reference in New Issue
Block a user