mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-23 01:59:43 +01:00
Add level resizing to undo/redo system
This commit is contained in:
parent
5b555f045c
commit
37b3091432
2 changed files with 41 additions and 15 deletions
|
@ -3417,6 +3417,14 @@ void process_editor_buffer(const bool undo)
|
||||||
graphics.foregrounddrawn = false;
|
graphics.foregrounddrawn = false;
|
||||||
ed.updatetiles = true;
|
ed.updatetiles = true;
|
||||||
break;
|
break;
|
||||||
|
case EditorUndoType_LEVEL_SIZE:
|
||||||
|
// Restore the level size
|
||||||
|
new_info.level_width = cl.mapwidth;
|
||||||
|
new_info.level_height = cl.mapheight;
|
||||||
|
|
||||||
|
cl.mapwidth = info.level_width;
|
||||||
|
cl.mapheight = info.level_height;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (undo)
|
if (undo)
|
||||||
|
@ -3582,6 +3590,8 @@ void editorinput(void)
|
||||||
}
|
}
|
||||||
else if (shift_down)
|
else if (shift_down)
|
||||||
{
|
{
|
||||||
|
int old_width = cl.mapwidth;
|
||||||
|
int old_height = cl.mapheight;
|
||||||
|
|
||||||
if (up_pressed) cl.mapheight--;
|
if (up_pressed) cl.mapheight--;
|
||||||
if (down_pressed) cl.mapheight++;
|
if (down_pressed) cl.mapheight++;
|
||||||
|
@ -3591,23 +3601,37 @@ void editorinput(void)
|
||||||
cl.mapwidth = SDL_clamp(cl.mapwidth, 1, cl.maxwidth);
|
cl.mapwidth = SDL_clamp(cl.mapwidth, 1, cl.maxwidth);
|
||||||
cl.mapheight = SDL_clamp(cl.mapheight, 1, cl.maxheight);
|
cl.mapheight = SDL_clamp(cl.mapheight, 1, cl.maxheight);
|
||||||
|
|
||||||
ed.updatetiles = true;
|
if (old_width != cl.mapwidth || old_height != cl.mapheight)
|
||||||
ed.changeroom = true;
|
{
|
||||||
graphics.backgrounddrawn = false;
|
|
||||||
graphics.foregrounddrawn = false;
|
|
||||||
|
|
||||||
ed.levx = POS_MOD(ed.levx, cl.mapwidth);
|
ed.updatetiles = true;
|
||||||
ed.levy = POS_MOD(ed.levy, cl.mapheight);
|
ed.changeroom = true;
|
||||||
|
graphics.backgrounddrawn = false;
|
||||||
|
graphics.foregrounddrawn = false;
|
||||||
|
|
||||||
char buffer[3 * SCREEN_WIDTH_CHARS + 1];
|
ed.levx = POS_MOD(ed.levx, cl.mapwidth);
|
||||||
vformat_buf(
|
ed.levy = POS_MOD(ed.levy, cl.mapheight);
|
||||||
buffer, sizeof(buffer),
|
|
||||||
loc::gettext("Mapsize is now [{width},{height}]"),
|
|
||||||
"width:int, height:int",
|
|
||||||
cl.mapwidth, cl.mapheight
|
|
||||||
);
|
|
||||||
|
|
||||||
ed.show_note(buffer);
|
char buffer[3 * SCREEN_WIDTH_CHARS + 1];
|
||||||
|
vformat_buf(
|
||||||
|
buffer, sizeof(buffer),
|
||||||
|
loc::gettext("Mapsize is now [{width},{height}]"),
|
||||||
|
"width:int, height:int",
|
||||||
|
cl.mapwidth, cl.mapheight
|
||||||
|
);
|
||||||
|
|
||||||
|
ed.show_note(buffer);
|
||||||
|
|
||||||
|
EditorUndoInfo info;
|
||||||
|
info.type = EditorUndoType_LEVEL_SIZE;
|
||||||
|
info.level_width = old_width;
|
||||||
|
info.level_height = old_height;
|
||||||
|
info.room_x = ed.levx;
|
||||||
|
info.room_y = ed.levy;
|
||||||
|
|
||||||
|
ed.undo_buffer.push_back(info);
|
||||||
|
ed.redo_buffer.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -142,6 +142,7 @@ enum EditorUndoTypes
|
||||||
EditorUndoType_ENTITY_ADDED, // Entity added
|
EditorUndoType_ENTITY_ADDED, // Entity added
|
||||||
EditorUndoType_ENTITY_REMOVED, // Entity removed
|
EditorUndoType_ENTITY_REMOVED, // Entity removed
|
||||||
EditorUndoType_ENTITY_MODIFIED, // Entity properties modified
|
EditorUndoType_ENTITY_MODIFIED, // Entity properties modified
|
||||||
|
EditorUndoType_LEVEL_SIZE // Level size modified
|
||||||
};
|
};
|
||||||
|
|
||||||
struct EditorUndoInfo
|
struct EditorUndoInfo
|
||||||
|
@ -155,7 +156,8 @@ struct EditorUndoInfo
|
||||||
int entity_id;
|
int entity_id;
|
||||||
CustomEntity entity;
|
CustomEntity entity;
|
||||||
RoomProperty room_data;
|
RoomProperty room_data;
|
||||||
|
int level_width;
|
||||||
|
int level_height;
|
||||||
};
|
};
|
||||||
|
|
||||||
class editorclass
|
class editorclass
|
||||||
|
|
Loading…
Reference in a new issue