Skip to content

Commit

Permalink
more 3ds changes, undo history fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vgmoose committed Dec 29, 2024
1 parent c44caae commit 4ae6ea3
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 19 deletions.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ APP_AUTHOR := vgmoose
APP_VERSION := 2.2

SOURCES += . gui edit
CFLAGS += -DUSE_KEYBOARD
CFLAGS += -DUSE_KEYBOARD
# -D_3DS_MOCK

ifeq (wiiu,$(MAKECMDGOALS))
SOURCES += $(CHESTO_DIR)/libs/wiiu_kbd libs/librpxloader/source
VPATH += $(CHESTO_DIR)/libs/wiiu_kbd
INCLUDES += ../libs/librpxloader/include
endif

include libs/chesto/Makefile
include libs/chesto/Makefile
6 changes: 3 additions & 3 deletions edit/Editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ bool Editor::appendHistory(const char* chars, int pos, bool isDelete)
{
// trim history size to current historyPos (removes future redo's)
if (historyPos != undoHistory.size() - 1)
undoHistory.erase(undoHistory.begin() + historyPos, undoHistory.end());
undoHistory.push_back({ .chars = chars, .isDelete = isDelete, .pos = pos, });
historyPos++;
undoHistory.erase(undoHistory.begin() + historyPos + 1, undoHistory.end());
undoHistory.push_back({ .chars = std::string(chars), .isDelete = isDelete, .pos = pos, });
historyPos = undoHistory.size() - 1;
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions gui/EditorView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ EditorView::EditorView(Editor* editor)
mainTextField->y = 70;
this->elements.push_back(mainTextField);

#if defined(_3DS_MOCK)
#if defined(_3DS) || defined(_3DS_MOCK)
mainTextField->x += 40;
mainTextField->y += SCREEN_HEIGHT;
#endif
Expand Down Expand Up @@ -64,7 +64,7 @@ void EditorView::reset_bounds()

// if this boolean is set, adjust the textfield in the direction of the cursor
if (keepCursorOnscreen) {
#if defined(_3DS_MOCK)
#if defined(_3DS) || defined(_3DS_MOCK)
if (cursor_y > SCREEN_HEIGHT - 150)
mainTextField->y -= h/2;
if (cursor_y < 50)
Expand Down
11 changes: 6 additions & 5 deletions gui/FileBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "../libs/chesto/src/Button.hpp"
#include "../libs/chesto/src/TextElement.hpp"
#include "../libs/chesto/src/Container.hpp"
#include "../libs/chesto/src/Constraint.hpp"
#include "FileCard.hpp"
#include "MainDisplay.hpp"
#include "TextQueryPopup.hpp"
Expand All @@ -27,6 +28,7 @@ FileBrowser::FileBrowser(const char* pwd)
cardsPerRow = LISTING_SCREEN_WIDTH / FILE_CARD_WIDTH;

x = ((SCREEN_WIDTH - (cardsPerRow * FILE_CARD_WIDTH)) / 4);
width = -1 * x; // the other margin
y = 0;

listfiles();
Expand Down Expand Up @@ -187,7 +189,7 @@ void FileBrowser::listfiles()
int count = 0;
int topOfList = 115;

#ifdef _3DS_MOCK
#if defined(_3DS) || defined(_3DS_MOCK)
topOfList = SCREEN_HEIGHT / 2 + 40;
#endif

Expand Down Expand Up @@ -290,16 +292,15 @@ void FileBrowser::listfiles()
}));

con->position(SCREEN_WIDTH - con->width - this->x * 2, topOfList - 85 / SCALER);
#ifdef _3DS_MOCK
#if defined(_3DS) || defined(_3DS_MOCK)
con->position(SCREEN_WIDTH / 2 - con->width / 2 - this->x, topOfList - 30);
path->position(10 / SCALER, topOfList - 60);

// for 3ds, the top screen will show the title initially
Container* titleCon = new Container(ROW_LAYOUT, 10);

titleCon->add((new ImageElement(RAMFS "res/icon.jpg"))->setSize(50, 50));
titleCon->add((new ImageElement(RAMFS "res/icon_nobg.png"))->setSize(50, 50));
titleCon->add(new TextElement("VGEdit", 30, &white));
titleCon->position(SCREEN_WIDTH / 2 - con->width / 2, SCREEN_HEIGHT / 4 - con->height);
titleCon->constrain(ALIGN_CENTER_HORIZONTAL);
this->elements.push_back(titleCon);

#endif
Expand Down
2 changes: 1 addition & 1 deletion gui/FileCard.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <string>
#include "../libs/chesto/src/Element.hpp"

#ifdef _3DS_MOCK
#if defined(_3DS) || defined(_3DS_MOCK)
#define FILE_CARD_WIDTH 80
#define LISTING_SCREEN_WIDTH (SCREEN_WIDTH - 80)
#else
Expand Down
2 changes: 2 additions & 0 deletions gui/MainDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ MainDisplay::MainDisplay()
{
RootDisplay::super();
backgroundColor = fromRGB(0x42, 0x45, 0x48);

RootDisplay::idleCursorPulsing = true;
}

void MainDisplay::openFile(bool isFolder, std::string* path)
Expand Down
2 changes: 1 addition & 1 deletion gui/TextQueryPopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ TextQueryPopup::TextQueryPopup(const char* prompt, const char* ctaText, std::fun
});
keyboard->preventEnterAndTab = true;

#if defined(_3DS_MOCK)
#if defined(_3DS) || defined(_3DS_MOCK)
keyboard->width = SCREEN_WIDTH - 140;
keyboard->position(40, 360);
#endif
Expand Down
8 changes: 4 additions & 4 deletions gui/Toolbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ bool Toolbar::commonHistoryLogic(bool isUndo, Editor* editor, TextInputElement*
bool isDelete = event.isDelete != isUndo;

int pos = event.pos;
std::string* chars = &event.chars;
std::string& chars = event.chars;

if (isDelete) {
editor->text->erase(pos, chars->length());
editor->text->erase(pos, chars.length());
} else {
editor->text->insert(pos, chars->c_str());
editor->text->insert(pos, chars.c_str());
}

// move cursor
Expand Down Expand Up @@ -217,7 +217,7 @@ void Toolbar::initButtons(EditorView* editorView)
editorView->keyboard->hidden = false;
editorView->keepCursorOnscreen = true;

#if defined(_3DS_MOCK)
#if defined(_3DS) || defined(_3DS_MOCK)
editorView->keyboard->width = SCREEN_WIDTH - 140;
editorView->keyboard->position(40, 360);
editorView->keyboard->updateSize();
Expand Down
2 changes: 1 addition & 1 deletion libs/chesto
Submodule chesto updated 221 files

0 comments on commit 4ae6ea3

Please sign in to comment.