Teleportation in editor
This commit is contained in:
@@ -52,6 +52,8 @@ bool quit_editor = false;
|
||||
|
||||
const std::string levelsDir = "levels";
|
||||
bool map_changed = false;
|
||||
MapObject *current_obj = nullptr;
|
||||
std::shared_ptr<MarioBlock> current_modifier = nullptr;
|
||||
|
||||
struct ToolType {
|
||||
enum Value {
|
||||
@@ -148,14 +150,12 @@ bool getFlag(uint64_t flag) {
|
||||
}
|
||||
|
||||
void saveMapCallback(void * /*UNUSED*/, Button * /*UNUSED*/) {
|
||||
std::cout << "SAVING" << std::endl;
|
||||
saveMap(levelsDir + FSLib::dir_divisor + level_name_text + ".marmap",
|
||||
global_vars.objects);
|
||||
map_changed = false;
|
||||
game_scenes.pop_back();
|
||||
}
|
||||
void loadMapDialogCallback(const std::string &level_name) {
|
||||
std::cout << "LOADING" << std::endl;
|
||||
map_changed = false;
|
||||
level_name_text = level_name.substr(0, level_name.length() - 7);
|
||||
setFlag(LOAD_MAP_FLAG);
|
||||
@@ -511,7 +511,6 @@ void updateWorld() {
|
||||
void handleKeyUp(SDL_Keycode key, SDLPP::Scene &scene) {
|
||||
switch (key) {
|
||||
case SDLK_ESCAPE:
|
||||
std::cout << "Eskape" << std::endl;
|
||||
game_scenes.push_back(mainMenuScene);
|
||||
break;
|
||||
case SDLK_a:
|
||||
@@ -681,6 +680,17 @@ MapObject &getSelectedObject() {
|
||||
return global_vars.objects[pos.getX()][pos.getY()];
|
||||
}
|
||||
|
||||
void setObjTeleport(const std::string &level) {
|
||||
if(current_obj == nullptr) {
|
||||
return;
|
||||
}
|
||||
if(level.empty()) {
|
||||
current_modifier->destroy();
|
||||
return;
|
||||
}
|
||||
current_obj->setModifier(TELEPORT_MODIFIER_ID, level);
|
||||
}
|
||||
|
||||
void placeTool(SDLPP::Scene &scene) {
|
||||
std::lock_guard<std::mutex> lock(render_mutex);
|
||||
map_changed = true;
|
||||
@@ -767,8 +777,9 @@ void placeTool(SDLPP::Scene &scene) {
|
||||
new_obj->setData(global_vars.current_tool->getData());
|
||||
if(new_obj->getId() == TELEPORT_MODIFIER_ID) {
|
||||
// TODO input
|
||||
new_obj->setTeleportLevel("test2.marmap");
|
||||
obj.setModifier(global_vars.current_tool->getId(), "test2.marmap");
|
||||
current_obj = &obj;
|
||||
current_modifier = new_obj;
|
||||
game_scenes.push_back(createTextScene(scene.getRendererShared(), setObjTeleport));
|
||||
}
|
||||
new_obj->getCollisions()[0]->setId(EDITOR_TERRAIN_ID);
|
||||
// TODO createModifierBlock
|
||||
@@ -783,6 +794,7 @@ void placeTool(SDLPP::Scene &scene) {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO move to a functions file, used in text_scene.cpp as well
|
||||
bool controlOrCommandPressed() {
|
||||
return SDL_GetModState() & KMOD_CTRL || SDL_GetModState() & KMOD_GUI;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user