This repository has been archived by the owner on Oct 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
122 additions
and
965 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,83 +1,19 @@ | ||
#include "game/console/common.h" | ||
|
||
#include "game/console/setup.h" | ||
#include "game/input.h" | ||
#include "game/text.h" | ||
#include "game/ui/widgets/console.h" | ||
|
||
#include <libtrx/game/console/common.h> | ||
|
||
static bool m_IsOpened = false; | ||
static UI_WIDGET *m_Console; | ||
|
||
void Console_Init(void) | ||
{ | ||
m_Console = UI_Console_Create(); | ||
} | ||
|
||
void Console_Shutdown(void) | ||
{ | ||
if (m_Console != NULL) { | ||
m_Console->free(m_Console); | ||
m_Console = NULL; | ||
} | ||
|
||
m_IsOpened = false; | ||
} | ||
|
||
void Console_Open(void) | ||
{ | ||
if (m_IsOpened) { | ||
UI_Console_HandleClose(m_Console); | ||
} | ||
m_IsOpened = true; | ||
UI_Console_HandleOpen(m_Console); | ||
} | ||
|
||
void Console_Close(void) | ||
{ | ||
UI_Console_HandleClose(m_Console); | ||
m_IsOpened = false; | ||
} | ||
|
||
bool Console_IsOpened(void) | ||
{ | ||
return m_IsOpened; | ||
} | ||
|
||
int32_t Console_GetMaxLineLength(void) | ||
{ | ||
return TEXT_MAX_STRING_SIZE - 1; | ||
} | ||
|
||
void Console_LogImpl(const char *const text) | ||
{ | ||
UI_Console_HandleLog(m_Console, text); | ||
} | ||
|
||
CONSOLE_COMMAND **Console_GetCommands(void) | ||
{ | ||
return g_ConsoleCommands; | ||
} | ||
|
||
void Console_Draw(void) | ||
void Console_DrawBackdrop(void) | ||
{ | ||
UI_Console_ScrollLogs(m_Console); | ||
|
||
#if 0 | ||
// TODO: draw screen quad | ||
int32_t sx = 0; | ||
int32_t sw = Viewport_GetWidth(); | ||
int32_t sh = Screen_GetRenderScale( | ||
// not entirely accurate, but good enough | ||
TEXT_HEIGHT * m_PromptScale | ||
+ MAX_LOG_LINES * TEXT_HEIGHT * m_LogScale, | ||
RSR_TEXT); | ||
int32_t sy = Viewport_GetHeight() - sh; | ||
|
||
RGBA_8888 top = { 0, 0, 0, 0 }; | ||
RGBA_8888 bottom = { 0, 0, 0, 196 }; | ||
|
||
Output_DrawScreenGradientQuad(sx, sy, sw, sh, top, top, bottom, bottom); | ||
#endif | ||
// TODO: implement me | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,5 @@ | ||
#pragma once | ||
|
||
#include <stdbool.h> | ||
#include <stdint.h> | ||
#include <libtrx/game/console/common.h> | ||
|
||
void Console_Init(void); | ||
void Console_Shutdown(void); | ||
void Console_Draw(void); | ||
|
||
void Console_Open(void); | ||
void Console_Close(void); | ||
bool Console_IsOpened(void); | ||
|
||
void Console_Log(const char *fmt, ...); | ||
void Console_ScrollLogs(void); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,19 @@ | ||
#include "game/ui/common.h" | ||
#include <libtrx/game/ui/common.h> | ||
|
||
#include <libtrx/vector.h> | ||
#include <windows.h> | ||
|
||
void UI_Init(void) | ||
UI_INPUT UI_TranslateInput(uint32_t system_keycode) | ||
{ | ||
UI_Events_Init(); | ||
} | ||
|
||
void UI_Shutdown(void) | ||
{ | ||
UI_Events_Shutdown(); | ||
} | ||
|
||
void UI_HandleKeyDown(const uint32_t key) | ||
{ | ||
const UI_EVENT event = { | ||
.name = "key_down", | ||
.sender = NULL, | ||
.data = (void *)(uintptr_t)key, | ||
}; | ||
UI_Events_Fire(&event); | ||
} | ||
|
||
void UI_HandleKeyUp(const uint32_t key) | ||
{ | ||
const UI_EVENT event = { | ||
.name = "key_up", | ||
.sender = NULL, | ||
.data = (void *)(uintptr_t)key, | ||
}; | ||
UI_Events_Fire(&event); | ||
} | ||
|
||
void UI_HandleChar(const uint32_t char_) | ||
{ | ||
const UI_EVENT event = { | ||
.name = "char", | ||
.sender = NULL, | ||
.data = (void *)(uintptr_t)char_, | ||
}; | ||
UI_Events_Fire(&event); | ||
// clang-format off | ||
switch (system_keycode) { | ||
case VK_LEFT: return UI_KEY_LEFT; | ||
case VK_RIGHT: return UI_KEY_RIGHT; | ||
case VK_HOME: return UI_KEY_HOME; | ||
case VK_END: return UI_KEY_END; | ||
case VK_BACK: return UI_KEY_BACK; | ||
case VK_RETURN: return UI_KEY_RETURN; | ||
case VK_ESCAPE: return UI_KEY_ESCAPE; | ||
} | ||
// clang-format on | ||
return -1; | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.