From 08f29fde5d7c36ac8365e98d5e02362709c36591 Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Thu, 15 Feb 2018 12:43:00 +0300 Subject: [PATCH] no message --- src/code.c | 29 +++-------------------------- src/console.c | 46 ++++++++++++++-------------------------------- src/dialog.c | 4 ++++ src/map.c | 27 ++------------------------- src/menu.c | 2 ++ src/music.c | 2 ++ src/sfx.c | 2 ++ src/sprite.c | 2 ++ src/studio.c | 26 -------------------------- src/studio.h | 2 -- 10 files changed, 31 insertions(+), 111 deletions(-) diff --git a/src/code.c b/src/code.c index 10ede71..de97b6c 100644 --- a/src/code.c +++ b/src/code.c @@ -884,6 +884,8 @@ static void processKeyboard(Code* code) { tic_mem* tic = code->tic; + if(tic->ram.input.keyboard.data == 0) return; + switch(getClipboardEvent(0)) { case TIC_CLIPBOARD_CUT: cutToClipboard(code); break; @@ -949,31 +951,7 @@ static void processKeyboard(Code* code) else if(keyWasPressed(tic_key_tab)) doTab(code, shift, ctrl); } - if(tic->ram.input.keyboard.data) - updateEditor(code); -} - -static void processGestures(Code* code) -{ - tic_point point = {0, 0}; - - if(getGesturePos(&point)) - { - if(code->scroll.gesture) - { - code->scroll.x = (code->scroll.start.x - point.x) / STUDIO_TEXT_WIDTH; - code->scroll.y = (code->scroll.start.y - point.y) / STUDIO_TEXT_HEIGHT; - - normalizeScroll(code); - } - else - { - code->scroll.start.x = point.x + code->scroll.x * STUDIO_TEXT_WIDTH; - code->scroll.start.y = point.y + code->scroll.y * STUDIO_TEXT_HEIGHT; - code->scroll.gesture = true; - } - } - else code->scroll.gesture = false; + updateEditor(code); } static void processMouse(Code* code) @@ -1070,7 +1048,6 @@ static void textEditTick(Code* code) } } - processGestures(code); processMouse(code); code->tic->api.clear(code->tic, getConfig()->theme.code.bg); diff --git a/src/console.c b/src/console.c index 7fb8f8e..a7031c5 100644 --- a/src/console.c +++ b/src/console.c @@ -2515,23 +2515,6 @@ static void setScroll(Console* console, s32 val) } } -static void processGesture(Console* console) -{ - tic_point point = {0, 0}; - - if(getGesturePos(&point)) - { - if(console->scroll.active) - setScroll(console, (console->scroll.start - point.y) / STUDIO_TEXT_HEIGHT); - else - { - console->scroll.start = point.y + console->scroll.pos * STUDIO_TEXT_HEIGHT; - console->scroll.active = true; - } - } - else console->scroll.active = false; -} - typedef struct { s32 major; @@ -2625,6 +2608,7 @@ static void tick(Console* console) } } + if(tic->ram.input.keyboard.data != 0) { if(keyWasPressed(tic_key_up)) onHistoryUp(console); else if(keyWasPressed(tic_key_down)) onHistoryDown(console); @@ -2652,28 +2636,26 @@ static void tick(Console* console) scrollConsole(console); console->cursor.delay = CONSOLE_CURSOR_DELAY; } - } - char sym = getKeyboardText(); + char sym = getKeyboardText(); - if(sym) - { - size_t size = strlen(console->inputBuffer); - - if(size < sizeof(console->inputBuffer)) + if(sym) { - char* pos = console->inputBuffer + console->inputPosition; - memmove(pos + 1, pos, strlen(pos)); + size_t size = strlen(console->inputBuffer); - *(console->inputBuffer + console->inputPosition) = sym; - console->inputPosition++; + if(size < sizeof(console->inputBuffer)) + { + char* pos = console->inputBuffer + console->inputPosition; + memmove(pos + 1, pos, strlen(pos)); + + *(console->inputBuffer + console->inputPosition) = sym; + console->inputPosition++; + } + + console->cursor.delay = CONSOLE_CURSOR_DELAY; } - - console->cursor.delay = CONSOLE_CURSOR_DELAY; } - processGesture(console); - if(console->tickCounter == 0) { if(!console->embed.yes) diff --git a/src/dialog.c b/src/dialog.c index 99026d8..89ef05b 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -93,6 +93,10 @@ static void onNo(Dialog* dlg) static void processKeyboard(Dialog* dlg) { + tic_mem* tic = dlg->tic; + + if(tic->ram.input.keyboard.data == 0) return; + if(keyWasPressed(tic_key_left)) { dlg->focus = (dlg->focus-1) % 2; diff --git a/src/map.c b/src/map.c index 9cdad0c..16a5a34 100644 --- a/src/map.c +++ b/src/map.c @@ -1008,6 +1008,8 @@ static void processKeyboard(Map* map) tic_mem* tic = map->tic; map->sheet.show = false; + if(tic->ram.input.keyboard.data == 0) return; + bool shift = tic->api.key(tic, tic_key_shift); bool ctrl = tic->api.key(tic, tic_key_ctrl); @@ -1055,36 +1057,11 @@ static void processKeyboard(Map* map) } } -static void processGesture(Map* map) -{ - tic_point point = {0, 0}; - - if(getGesturePos(&point)) - { - if(map->scroll.gesture) - { - map->scroll.x = map->scroll.start.x - point.x; - map->scroll.y = map->scroll.start.y - point.y; - - normalizeMap(&map->scroll.x, &map->scroll.y); - } - else - { - map->scroll.start.x = point.x + map->scroll.x; - map->scroll.start.y = point.y + map->scroll.y; - map->scroll.gesture = true; - } - } - else map->scroll.gesture = false; -} - static void tick(Map* map) { map->tickCounter++; processKeyboard(map); - processGesture(map); - map->tic->api.clear(map->tic, TIC_COLOR_BG); drawSheet(map, TIC80_WIDTH - TIC_SPRITESHEET_SIZE - 1, TOOLBAR_SIZE); diff --git a/src/menu.c b/src/menu.c index ebb65ee..c06f5ca 100644 --- a/src/menu.c +++ b/src/menu.c @@ -436,6 +436,8 @@ static void processKeyboard(Menu* menu) { tic_mem* tic = menu->tic; + if(tic->ram.input.keyboard.data == 0) return; + if(menu->gamepad.selected < 0) return; diff --git a/src/music.c b/src/music.c index ade0a38..738b00f 100644 --- a/src/music.c +++ b/src/music.c @@ -1003,6 +1003,8 @@ static void processKeyboard(Music* music) { tic_mem* tic = music->tic; + if(tic->ram.input.keyboard.data == 0) return; + switch(getClipboardEvent()) { case TIC_CLIPBOARD_CUT: copyToClipboard(music, true); break; diff --git a/src/sfx.c b/src/sfx.c index 98a8bac..fe8d3e2 100644 --- a/src/sfx.c +++ b/src/sfx.c @@ -631,6 +631,8 @@ static void processKeyboard(Sfx* sfx) { tic_mem* tic = sfx->tic; + if(tic->ram.input.keyboard.data == 0) return; + bool ctrl = tic->api.key(tic, tic_key_ctrl); s32 keyboardButton = -1; diff --git a/src/sprite.c b/src/sprite.c index 5e38c00..bc2a0c7 100644 --- a/src/sprite.c +++ b/src/sprite.c @@ -1431,6 +1431,8 @@ static void processKeyboard(Sprite* sprite) { tic_mem* tic = sprite->tic; + if(tic->ram.input.keyboard.data == 0) return; + switch(getClipboardEvent()) { case TIC_CLIPBOARD_CUT: cutToClipboard(sprite); break; diff --git a/src/studio.c b/src/studio.c index 4a12a2f..22ed3c2 100644 --- a/src/studio.c +++ b/src/studio.c @@ -107,12 +107,6 @@ static struct MouseState state[3]; } mouse; - struct - { - tic_point pos; - bool active; - } gesture; - tic_key keycodes[KEYMAP_COUNT]; struct @@ -198,12 +192,6 @@ static struct .prevMode = TIC_CODE_MODE, .dialogMode = TIC_CONSOLE_MODE, - .gesture = - { - .pos = {0, 0}, - .active = false, - }, - .keycodes = { tic_key_up, @@ -1053,18 +1041,6 @@ bool checkMouseDown(const tic_rect* rect, s32 button) return state->down && pointInRect(&state->start, rect); } -bool getGesturePos(tic_point* pos) -{ - if(studioImpl.gesture.active) - { - *pos = studioImpl.gesture.pos; - - return true; - } - - return false; -} - void setCursor(tic_cursor id) { tic_mem* tic = studioImpl.studio.tic; @@ -1565,8 +1541,6 @@ static void renderStudio() showTooltip(""); - studioImpl.gesture.active = false; - { const tic_sfx* sfx = NULL; const tic_music* music = NULL; diff --git a/src/studio.h b/src/studio.h index 765c525..8a19039 100644 --- a/src/studio.h +++ b/src/studio.h @@ -94,8 +94,6 @@ bool checkMousePos(const tic_rect* rect); bool checkMouseClick(const tic_rect* rect, s32 button); bool checkMouseDown(const tic_rect* rect, s32 button); -bool getGesturePos(tic_point* pos); - void drawToolbar(tic_mem* tic, u8 color, bool bg); void drawBitIcon(s32 x, s32 y, const u8* ptr, u8 color);