mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-04-15 17:46:03 +03:00
feat(console): add background drawing for console
This commit is contained in:
parent
43f6d1f3cd
commit
134d85bce6
@ -1,7 +1,12 @@
|
||||
#include "console/Screen.hpp"
|
||||
#include "console/Types.hpp"
|
||||
#include "gx/Buffer.hpp"
|
||||
#include "gx/Coordinate.hpp"
|
||||
#include "gx/Device.hpp"
|
||||
#include "gx/Draw.hpp"
|
||||
#include "gx/Font.hpp"
|
||||
#include "gx/Gx.hpp"
|
||||
#include "gx/RenderState.hpp"
|
||||
#include "gx/Screen.hpp"
|
||||
#include <storm/String.hpp>
|
||||
#include <tempest/Rect.hpp>
|
||||
@ -11,15 +16,68 @@ static float s_caretpixwidth;
|
||||
static float s_caretpixheight;
|
||||
static float s_fontHeight = 0.02f;
|
||||
static char s_fontName[STORM_MAX_PATH];
|
||||
static int32_t s_highlightState;
|
||||
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) {
|
||||
static CImVector s_colorArray[] = {
|
||||
{ 0xFF, 0xFF, 0xFF, 0xFF }, // DEFAULT_COLOR
|
||||
{ 0xFF, 0xFF, 0xFF, 0xFF }, // INPUT_COLOR
|
||||
{ 0x80, 0x80, 0x80, 0xFF }, // ECHO_COLOR
|
||||
{ 0x00, 0x00, 0xFF, 0xFF }, // ERROR_COLOR
|
||||
{ 0x00, 0xFF, 0xFF, 0xFF }, // WARNING_COLOR
|
||||
{ 0xFF, 0xFF, 0xFF, 0xFF }, // GLOBAL_COLOR
|
||||
{ 0xFF, 0xFF, 0xFF, 0xFF }, // ADMIN_COLOR
|
||||
{ 0xFF, 0xFF, 0xFF, 0x80 }, // HIGHLIGHT_COLOR
|
||||
{ 0x00, 0x00, 0x00, 0x80 }, // BACKGROUND_COLOR
|
||||
};
|
||||
|
||||
void DrawBackground() {
|
||||
uint16_t indices[] = {
|
||||
0, 1, 2, 3
|
||||
};
|
||||
|
||||
C3Vector position[] = {
|
||||
{ s_rect.left, s_rect.bottom, 0.0f },
|
||||
{ s_rect.right, s_rect.bottom, 0.0f },
|
||||
{ s_rect.left, s_rect.top, 0.0f },
|
||||
{ s_rect.right, s_rect.top, 0.0f }
|
||||
};
|
||||
|
||||
GxRsPush();
|
||||
|
||||
GxRsSet(GxRs_Lighting, 0);
|
||||
GxRsSet(GxRs_Fog, 0);
|
||||
GxRsSet(GxRs_DepthTest, 0);
|
||||
GxRsSet(GxRs_DepthWrite, 0);
|
||||
GxRsSet(GxRs_Culling, 0);
|
||||
GxRsSet(GxRs_PolygonOffset, 0.0f);
|
||||
GxRsSet(GxRs_BlendingMode, GxBlend_Alpha);
|
||||
GxRsSet(GxRs_AlphaRef, CGxDevice::s_alphaRef[GxBlend_Alpha]);
|
||||
|
||||
GxPrimLockVertexPtrs(4, position, sizeof(C3Vector), nullptr, 0, &s_colorArray[BACKGROUND_COLOR], 0, nullptr, 0, nullptr, 0, nullptr, 0);
|
||||
GxDrawLockedElements(GxPrim_TriangleStrip, 4, indices);
|
||||
GxPrimUnlockVertexPtrs();
|
||||
|
||||
GxRsPop();
|
||||
}
|
||||
|
||||
void DrawHighLight() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void PaintBackground(void* param, const RECTF* rect, const RECTF* visible, float elapsedSec) {
|
||||
if (s_rect.bottom < 1.0f) {
|
||||
DrawBackground();
|
||||
|
||||
if (s_highlightState) {
|
||||
DrawHighLight();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PaintText(void* param, const RECTF* rect, const RECTF* visible, float elapsedSec) {
|
||||
// TODO
|
||||
}
|
||||
|
17
src/console/Types.hpp
Normal file
17
src/console/Types.hpp
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef CONSOLE_TYPES_HPP
|
||||
#define CONSOLE_TYPES_HPP
|
||||
|
||||
enum COLOR_T {
|
||||
DEFAULT_COLOR,
|
||||
INPUT_COLOR,
|
||||
ECHO_COLOR,
|
||||
ERROR_COLOR,
|
||||
WARNING_COLOR,
|
||||
GLOBAL_COLOR,
|
||||
ADMIN_COLOR,
|
||||
HIGHLIGHT_COLOR,
|
||||
BACKGROUND_COLOR,
|
||||
NUM_COLORTYPES,
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user