le readme
This commit is contained in:
@@ -1842,6 +1842,7 @@ imgui_init
|
||||
Preview* preview,
|
||||
Settings* settings,
|
||||
Tool* tool,
|
||||
UndoStack* undoStack,
|
||||
SDL_Window* window,
|
||||
SDL_GLContext* glContext
|
||||
)
|
||||
@@ -1859,6 +1860,7 @@ imgui_init
|
||||
self->preview = preview;
|
||||
self->settings = settings;
|
||||
self->tool = tool;
|
||||
self->undoStack = undoStack;
|
||||
self->window = window;
|
||||
self->glContext = glContext;
|
||||
|
||||
@@ -1923,6 +1925,9 @@ imgui_tick(Imgui* self)
|
||||
|
||||
_imgui_taskbar(self);
|
||||
_imgui_dock(self);
|
||||
|
||||
if (key_press(&self->input->keyboard, INPUT_KEYS[INPUT_UNDO]))
|
||||
undo_stack_pop(self->undoStack, self->anm2);
|
||||
}
|
||||
|
||||
void
|
||||
|
@@ -8,6 +8,7 @@
|
||||
#include "input.h"
|
||||
#include "settings.h"
|
||||
#include "tool.h"
|
||||
#include "undo_stack.h"
|
||||
|
||||
#define IMGUI_IMPL_OPENGL_LOADER_CUSTOM
|
||||
#define IMGUI_ENABLE_DOCKING
|
||||
@@ -100,6 +101,7 @@ struct Imgui
|
||||
Preview* preview = NULL;
|
||||
Settings* settings = NULL;
|
||||
Tool* tool = NULL;
|
||||
UndoStack* undoStack = NULL;
|
||||
SDL_Window* window = NULL;
|
||||
SDL_GLContext* glContext = NULL;
|
||||
bool isSwap = false;
|
||||
@@ -121,6 +123,7 @@ imgui_init
|
||||
Preview* preview,
|
||||
Settings* settings,
|
||||
Tool* tool,
|
||||
UndoStack* undoStack,
|
||||
SDL_Window* window,
|
||||
SDL_GLContext* glContext
|
||||
);
|
||||
|
@@ -233,7 +233,7 @@ enum KeyType
|
||||
KEY_RGUI = 231
|
||||
};
|
||||
|
||||
#define INPUT_COUNT (INPUT_ZOOM_OUT + 1)
|
||||
#define INPUT_COUNT (INPUT_UNDO + 1)
|
||||
enum InputType
|
||||
{
|
||||
INPUT_PAN,
|
||||
@@ -247,7 +247,8 @@ enum InputType
|
||||
INPUT_ROTATE_LEFT,
|
||||
INPUT_ROTATE_RIGHT,
|
||||
INPUT_ZOOM_IN,
|
||||
INPUT_ZOOM_OUT
|
||||
INPUT_ZOOM_OUT,
|
||||
INPUT_UNDO
|
||||
};
|
||||
|
||||
static const KeyType INPUT_KEYS[INPUT_COUNT]
|
||||
@@ -263,7 +264,8 @@ static const KeyType INPUT_KEYS[INPUT_COUNT]
|
||||
KEY_Q,
|
||||
KEY_W,
|
||||
KEY_1,
|
||||
KEY_2
|
||||
KEY_2,
|
||||
KEY_Z
|
||||
};
|
||||
|
||||
struct Keyboard
|
||||
|
24
src/snapshots.cpp
Normal file
24
src/snapshots.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#include "undo_stack.h"
|
||||
|
||||
void
|
||||
undo_stack_push(Snapshots* self, Anm2* anm2)
|
||||
{
|
||||
if (self->top >= UNDO_STACK_MAX)
|
||||
{
|
||||
memmove(&self->snapshots[0], &self->snapshots[1], sizeof(Anm2) * (UNDO_STACK_MAX - 1));
|
||||
self->top = UNDO_STACK_MAX - 1;
|
||||
}
|
||||
|
||||
self->snapshots[self->top++] = *anm2;
|
||||
}
|
||||
|
||||
bool
|
||||
undo_stack_pop(Snapshots* self, Anm2* anm2)
|
||||
{
|
||||
if (self->top == 0)
|
||||
return false;
|
||||
|
||||
*anm2 = self->snapshots[--self->top];
|
||||
|
||||
return true;
|
||||
}
|
22
src/snapshots.h
Normal file
22
src/snapshots.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include "anm2.h"
|
||||
|
||||
#define SNAPSHOT_STACK_MAX 100
|
||||
|
||||
struct SnapshotStack
|
||||
{
|
||||
Anm2 snapshots[SNAPSHOT_STACK_MAX];
|
||||
s32 top = 0;
|
||||
};
|
||||
|
||||
struct Snapshots
|
||||
{
|
||||
SnapshotStack undoStack;
|
||||
SnapshotStack redoStack;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void undo_stack_push(UndoStack* self, Anm2* anm2);
|
||||
bool undo_stack_pop(UndoStack* self, Anm2* anm2);
|
@@ -143,6 +143,7 @@ init(State* state)
|
||||
&state->preview,
|
||||
&state->settings,
|
||||
&state->tool,
|
||||
&state->undoStack,
|
||||
state->window,
|
||||
&state->glContext
|
||||
);
|
||||
|
@@ -22,6 +22,7 @@ struct State
|
||||
Resources resources;
|
||||
Settings settings;
|
||||
Tool tool;
|
||||
UndoStack undoStack;
|
||||
bool isArgument = false;
|
||||
bool isRunning = true;
|
||||
char argument[PATH_MAX] = STRING_EMPTY;
|
||||
|
Reference in New Issue
Block a user