Compare commits

..

No commits in common. "3a80fab3ddcf26d56517f928cbd542ce112ebf2d" and "4143af996217f5dd3d875b459bb5f37f8364a597" have entirely different histories.

2 changed files with 5 additions and 56 deletions

View File

@ -11,7 +11,6 @@
#include "../editor_visitor.hpp" #include "../editor_visitor.hpp"
#include "../tool_box.hpp" #include "../tool_box.hpp"
#include "../blocks/coineditorblock.hpp" #include "../blocks/coineditorblock.hpp"
#include <SDL2/SDL_keycode.h>
#include <array> #include <array>
#ifdef _WIN32 #ifdef _WIN32
@ -37,8 +36,6 @@
#define CHARACTER_LEFT_ENABLED_FLAG 0x00000100 #define CHARACTER_LEFT_ENABLED_FLAG 0x00000100
#define CHARACTER_RIGHT_ENABLED_FLAG 0x00000200 #define CHARACTER_RIGHT_ENABLED_FLAG 0x00000200
#define LOAD_MAP_FLAG 0x00000400 #define LOAD_MAP_FLAG 0x00000400
#define TEXT_UPDATE_FLAG 0x00000800
#define TEXT_INPUT_FLAG 0x00001000
#define TOOLS_WIDTH 4 #define TOOLS_WIDTH 4
#define CHARACTER_WIDTH 3 #define CHARACTER_WIDTH 3
@ -123,9 +120,6 @@ std::shared_ptr<SDLPP::Scene> editorScene;
SceneStruct mainMenuScene; SceneStruct mainMenuScene;
//SceneStruct fileChoiceScene; //SceneStruct fileChoiceScene;
std::shared_ptr<SDLPP::TextRenderer> global_test_text{};
std::string global_test_text_text{};
void openMapEditor(std::shared_ptr<SDLPP::Scene> &scene, const std::string &filename); void openMapEditor(std::shared_ptr<SDLPP::Scene> &scene, const std::string &filename);
void setFlag(uint64_t flag) { void setFlag(uint64_t flag) {
@ -779,29 +773,7 @@ void pollEvents(std::shared_ptr<SDLPP::Scene> &scene) {
setFlag(QUIT_FLAG); setFlag(QUIT_FLAG);
break; break;
case SDL_KEYUP: case SDL_KEYUP:
if(!getFlag(TEXT_INPUT_FLAG)) {
handleKeyUp(event.key.keysym.sym, *scene); handleKeyUp(event.key.keysym.sym, *scene);
} else {
if ( event.key.keysym.sym == SDLK_ESCAPE || event.key.keysym.sym == SDLK_RETURN ) {
SDL_StopTextInput();
unsetFlag(TEXT_INPUT_FLAG);
}
}
break;
case SDL_KEYDOWN:
if(getFlag(TEXT_INPUT_FLAG)) {
if( event.key.keysym.sym == SDLK_BACKSPACE && !global_test_text_text.empty() ) {
global_test_text_text.pop_back();
setFlag(TEXT_UPDATE_FLAG);
} else if( event.key.keysym.sym == SDLK_c && SDL_GetModState() & KMOD_CTRL ) {
// handle copy
SDL_SetClipboardText( global_test_text_text.c_str() );
} else if( event.key.keysym.sym == SDLK_v && SDL_GetModState() & KMOD_CTRL ) {
// handle paste
global_test_text_text += SDL_GetClipboardText();
setFlag(TEXT_UPDATE_FLAG);
}
}
break; break;
case SDL_WINDOWEVENT: case SDL_WINDOWEVENT:
if (event.window.event == SDL_WINDOWEVENT_RESIZED) { if (event.window.event == SDL_WINDOWEVENT_RESIZED) {
@ -866,10 +838,6 @@ void pollEvents(std::shared_ptr<SDLPP::Scene> &scene) {
global_vars.current_tool->onScrollDown(); global_vars.current_tool->onScrollDown();
} }
break; break;
case SDL_TEXTINPUT:
global_test_text_text += event.text.text;
setFlag(TEXT_UPDATE_FLAG);
break;
default: default:
break; break;
} }
@ -998,9 +966,10 @@ void populateWorldType(
scene->addObject(tool_text); scene->addObject(tool_text);
} }
void testButtonFunc(void */*UNUSED*/, Button */*UNUSED*/) { void testButtonFunc(void *input, Button *caller) {
setFlag(TEXT_INPUT_FLAG); auto actual = static_cast<int*>(input);
SDL_StartTextInput(); std::cout << "NUM: " << *actual << std::endl;
caller->disable();
} }
void openMapEditor(std::shared_ptr<SDLPP::Scene> &scene, const std::string &filename) { void openMapEditor(std::shared_ptr<SDLPP::Scene> &scene, const std::string &filename) {
@ -1063,13 +1032,6 @@ void openMapEditor(std::shared_ptr<SDLPP::Scene> &scene, const std::string &file
createGrid(BLOCK_SIZE, 1 - (MAP_HEIGHT + 3) * BLOCK_SIZE, OVERWORLD_WIDTH, createGrid(BLOCK_SIZE, 1 - (MAP_HEIGHT + 3) * BLOCK_SIZE, OVERWORLD_WIDTH,
2, scene); 2, scene);
global_test_text = std::make_shared<SDLPP::TextRenderer>(
0.3, 0.05, BLOCK_SIZE*4, BLOCK_SIZE*2,
renderer, "TEST TEXT", font_config, SDLPP_TEXT_CENTER);
global_test_text->setAlignment(SDLPP::OBJ_CENTER, SDLPP::OBJ_CENTER);
global_test_text->setPermanent();
scene->addObject(global_test_text);
global_vars.map.max_page = global_vars.objects.size() - MAP_WIDTH; global_vars.map.max_page = global_vars.objects.size() - MAP_WIDTH;
// arrowInputs[1] - rightMapInput, arrowInputs[0] - leftMapInput // arrowInputs[1] - rightMapInput, arrowInputs[0] - leftMapInput
toolMoveUpdateButtons(arrowInputs[1].other_button.get(), arrowInputs[0].other_button.get(), global_vars.map.cur_page, global_vars.map.max_page, true); toolMoveUpdateButtons(arrowInputs[1].other_button.get(), arrowInputs[0].other_button.get(), global_vars.map.cur_page, global_vars.map.max_page, true);
@ -1255,10 +1217,6 @@ std::shared_ptr<SDLPP::Scene> createEditorMainScene(std::shared_ptr<SDLPP::Rende
toolMoveUpdateButtons(right_character_input.other_button.get(), global_vars.buttons.back().get(), global_vars.tool.cur_page_characters, global_vars.tool.max_page_characters, false); toolMoveUpdateButtons(right_character_input.other_button.get(), global_vars.buttons.back().get(), global_vars.tool.cur_page_characters, global_vars.tool.max_page_characters, false);
left_character_input.other_button = global_vars.buttons.back(); left_character_input.other_button = global_vars.buttons.back();
global_vars.buttons.emplace_back(std::make_shared<Button>(0, 0, 0.2, 0.2, renderer, "Write Button", default_button_theme, testButtonFunc, nullptr));
global_vars.buttons.back()->setPermanent();
global_vars.buttons.back()->setButtonIndex(global_vars.buttons.size() - 1);
openMapEditor(scene, ""); openMapEditor(scene, "");
return scene; return scene;
@ -1279,11 +1237,6 @@ void editorAdditionalRender(std::shared_ptr<SDLPP::Scene> &scene) {
openMapEditor(editorScene, "test_binary.bin"); openMapEditor(editorScene, "test_binary.bin");
unsetFlag(LOAD_MAP_FLAG); unsetFlag(LOAD_MAP_FLAG);
} }
if (getFlag(TEXT_UPDATE_FLAG)) {
global_test_text->changeText(global_test_text_text);
unsetFlag(TEXT_UPDATE_FLAG);
setFlag(UPDATE_FLAG);
}
} }
SceneStruct createEditorScene(std::shared_ptr<SDLPP::Renderer> &renderer) { SceneStruct createEditorScene(std::shared_ptr<SDLPP::Renderer> &renderer) {

View File

@ -78,10 +78,6 @@ void TextRenderer::render() {
} }
} }
void TextRenderer::updateTexture() { void TextRenderer::updateTexture() {
if(_text.empty()) {
texture = NULL;
return;
}
int fontSize = 0.6 * getRect().h; int fontSize = 0.6 * getRect().h;
_config->getFont()->changeFontSize( fontSize ); _config->getFont()->changeFontSize( fontSize );
int intOutline = _config->getOutlineSize(); int intOutline = _config->getOutlineSize();