diff options
| author | nathan <nathansmith@disroot.org> | 2025-11-21 11:27:12 +0000 |
|---|---|---|
| committer | nathan <nathansmith@disroot.org> | 2025-11-21 11:27:12 +0000 |
| commit | 52a58016c7217942ab06988cc9adacc6e76689ca (patch) | |
| tree | 7b2fc58d2f1f331c48a47096d1d3e809045374f0 | |
| parent | e00d5a923f69bd0b95b0ccf11d98f507fe6f08aa (diff) | |
| download | FindThings-52a58016c7217942ab06988cc9adacc6e76689ca.tar.gz FindThings-52a58016c7217942ab06988cc9adacc6e76689ca.tar.bz2 FindThings-52a58016c7217942ab06988cc9adacc6e76689ca.zip | |
cross hair and clear background thingy
| -rw-r--r-- | src/game.c | 32 | ||||
| -rw-r--r-- | src/settings.c | 6 | ||||
| -rw-r--r-- | src/settings.h | 6 | ||||
| -rw-r--r-- | src/ui.c | 6 |
4 files changed, 48 insertions, 2 deletions
@@ -112,7 +112,7 @@ void initGame(Game* game) 100.0, 100.0}); addWindowToWindowManager(&game->wm, window); - window = createFloatingWindow("test2", + window = createFloatingWindow("test2",\ (Rectangle){200.0, 200.0, 100.0, 100.0}); window.callback = testFloatingWindowCallback; addWindowToWindowManager(&game->wm, window); @@ -170,6 +170,29 @@ void drawGameScreen(Game* game) } } +void drawCrosshair(float crossHairSize, float crossHairThickness, Color color) +{ + float screenHalfWidth = GetRenderWidth() / 2.0; + float screenHalfHeight = GetRenderHeight() / 2.0; + float halfThickness = crossHairThickness / 2.0; + + // Vertical. + DrawLineEx( + (Vector2){screenHalfWidth - crossHairSize, + screenHalfHeight}, + (Vector2){screenHalfWidth + crossHairSize, + screenHalfHeight}, + crossHairThickness, color); + + // Horizontal. + DrawLineEx( + (Vector2){screenHalfWidth, + screenHalfHeight - crossHairSize}, + (Vector2){screenHalfWidth, + screenHalfHeight + crossHairSize}, + crossHairThickness, color); +} + void updateGameScene(Game* game) { // Handle toggle cursor. @@ -207,6 +230,13 @@ void updateGameScene(Game* game) drawGameScreen(game); updateWindowManager(&game->wm, game); + + if (!game->isCursorEnabled) + { + drawCrosshair(game->settings.crossHairSize, + game->settings.crossHairThickness, + game->settings.crossHairColor); + } } void handleGameResize(Game* game) diff --git a/src/settings.c b/src/settings.c index 776647e..7720c64 100644 --- a/src/settings.c +++ b/src/settings.c @@ -14,12 +14,16 @@ Settings defaultSettings() .gamma = 0.6, .colorCount = 11.0, .maxUpdateDistance = 255.0, + .nonEditWindowAlpha = 255.0 * 0.75, + .crossHairSize = 8.0, + .crossHairThickness = 3.0, + .crossHairColor = BLUE, .mouseSpeed = 0.1, .forwardKey = KEY_W, .backwardKey = KEY_S, .rightKey = KEY_D, .leftKey = KEY_A, - .toggleCursorKey = KEY_LEFT_ALT, + .toggleCursorKey = KEY_C, .interactKey = KEY_E }; } diff --git a/src/settings.h b/src/settings.h index 36d311f..5a37ab9 100644 --- a/src/settings.h +++ b/src/settings.h @@ -27,6 +27,12 @@ typedef struct { // Update. float maxUpdateDistance; + // UI. + float nonEditWindowAlpha; // Alpha for windows in non-editable mode. + float crossHairSize; + float crossHairThickness; + Color crossHairColor; + // Controls. float mouseSpeed; KeyboardKey forwardKey; @@ -1,4 +1,5 @@ #include "ui.h" +#include "game.h" FloatingWindow createFloatingWindow(const char* title, Rectangle rect) { @@ -185,6 +186,11 @@ FocusCommand updateFloatingWindowNotMinimized(FloatingWindow* window, window->rect.width, window->rect.height - RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT }; + + Color color = GetColor(GuiGetStyle(DEFAULT, BACKGROUND_COLOR)); + color.a = game->settings.nonEditWindowAlpha; + + DrawRectangleRec(scissor, color); } bool requireScissor = window->rect.width < window->contentSize.x |
