feat(console): initialize console screen

This commit is contained in:
fallenoak 2023-04-07 23:06:08 -05:00
parent 0003d5bd4b
commit 6b4c5e9179
No known key found for this signature in database
GPG Key ID: 7628F8E61AEA070D
4 changed files with 64 additions and 1 deletions

View File

@ -4,6 +4,7 @@
#include "console/CVar.hpp"
#include "console/Client.hpp"
#include "console/Device.hpp"
#include "console/Screen.hpp"
#include "db/Db.hpp"
#include "glue/CGlueMgr.hpp"
#include "gx/Screen.hpp"
@ -72,7 +73,7 @@ int32_t InitializeEngineCallback(const void* a1, void* a2) {
// }
ScrnInitialize(0);
// ConsoleScreenInitialize(a2);
ConsoleScreenInitialize(nullptr); // TODO argument
// s_cvarTextureFilteringMode = CVar::Register(
// "textureFilteringMode",

View File

@ -14,6 +14,7 @@ target_include_directories(console
target_link_libraries(console
PUBLIC
common
gx
storm
PRIVATE
client

55
src/console/Screen.cpp Normal file
View File

@ -0,0 +1,55 @@
#include "console/Screen.hpp"
#include "gx/Coordinate.hpp"
#include "gx/Font.hpp"
#include "gx/Gx.hpp"
#include "gx/Screen.hpp"
#include <storm/String.hpp>
#include <tempest/Rect.hpp>
static CGxStringBatch* s_batch;
static float s_caretpixwidth;
static float s_caretpixheight;
static float s_fontHeight = 0.02f;
static char s_fontName[STORM_MAX_PATH];
static HLAYER s_layerBackground;
static HLAYER s_layerText;
static RECTF s_rect = { 0.0f, 1.0f, 1.0f, 1.0f };
static HTEXTFONT s_textFont;
void PaintBackground(void* param, const RECTF* rect, const RECTF* visible, float elapsedSec) {
// TODO
}
void PaintText(void* param, const RECTF* rect, const RECTF* visible, float elapsedSec) {
// TODO
}
void RegisterHandlers() {
// TODO
}
void ConsoleScreenInitialize(const char* title) {
CRect windowSize;
GxCapsWindowSize(windowSize);
auto width = windowSize.maxX - windowSize.minX;
auto height = windowSize.maxY - windowSize.minY;
s_caretpixwidth = width == 0.0f ? 1.0f : 1.0f / width;
s_caretpixheight = height == 0.0f ? 1.0f : 1.0f / height;
SStrCopy(s_fontName, "Fonts\\ARIALN.ttf", sizeof(s_fontName));
s_textFont = TextBlockGenerateFont(s_fontName, 0, NDCToDDCHeight(s_fontHeight));
ScrnLayerCreate(&s_rect, 6.0f, 0x1 | 0x2, nullptr, PaintBackground, &s_layerBackground);
ScrnLayerCreate(&s_rect, 7.0f, 0x1 | 0x2, nullptr, PaintText, &s_layerText);
RegisterHandlers();
// TODO register commands
// TODO EventSetConfirmCloseCallback(EventCloseCallback, 0);
// TODO ConsoleCommandExecute("ver", 1);
s_batch = GxuFontCreateBatch(false, false);
}

6
src/console/Screen.hpp Normal file
View File

@ -0,0 +1,6 @@
#ifndef CONSOLE_SCREEN_HPP
#define CONSOLE_SCREEN_HPP
void ConsoleScreenInitialize(const char* title);
#endif