Adding back GLFW
This commit is contained in:
@ -17,6 +17,7 @@ target_include_directories(${DAWN_TARGET_NAME}
|
||||
# Subdirs
|
||||
add_subdirectory(assert)
|
||||
add_subdirectory(rpg)
|
||||
add_subdirectory(ui)
|
||||
|
||||
# Sources
|
||||
target_sources(${DAWN_TARGET_NAME}
|
||||
|
@ -10,6 +10,9 @@
|
||||
#include "input.h"
|
||||
#include "display/display.h"
|
||||
#include "rpg/world/maps/testmap.h"
|
||||
#include "ui/textbox.h"
|
||||
|
||||
#include <font8x8_basic.h>
|
||||
|
||||
map_t MAP;
|
||||
game_t GAME;
|
||||
@ -20,7 +23,8 @@ void gameInit() {
|
||||
timeInit();
|
||||
inputInit();
|
||||
displayInit();
|
||||
|
||||
textboxInit();
|
||||
|
||||
testMapInit(&MAP);
|
||||
gameSetMap(&MAP);
|
||||
}
|
||||
|
@ -1,17 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2024 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "dusk.h"
|
||||
|
||||
typedef struct {
|
||||
|
||||
} cutsceneevent_t;
|
||||
|
||||
typedef struct {
|
||||
|
||||
} cutscene_t;
|
@ -10,6 +10,7 @@
|
||||
#include "rpg/world/map.h"
|
||||
#include "assert/assert.h"
|
||||
#include "time.h"
|
||||
#include "ui/textbox.h"
|
||||
|
||||
void entityInit(
|
||||
entity_t *entity,
|
||||
@ -69,6 +70,7 @@ void entityUpdate(entity_t *entity) {
|
||||
break;
|
||||
|
||||
case ENTITY_STATE_TALKING:
|
||||
if(!textboxIsOpen()) entity->state = ENTITY_STATE_IDLE;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "rpg/world/map.h"
|
||||
#include "input.h"
|
||||
#include "assert/assert.h"
|
||||
#include "ui/textbox.h"
|
||||
|
||||
void playerInit(entity_t *entity) {
|
||||
assertTrue(entity->type == ENTITY_TYPE_PLAYER, "Entity is not a player.");
|
||||
@ -44,6 +45,7 @@ void playerUpdate(entity_t *entity) {
|
||||
|
||||
target->state = ENTITY_STATE_TALKING;
|
||||
entity->state = ENTITY_STATE_TALKING;
|
||||
textboxSetText("Hello Player");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
12
src/dawn/ui/CMakeLists.txt
Normal file
12
src/dawn/ui/CMakeLists.txt
Normal file
@ -0,0 +1,12 @@
|
||||
# Copyright (c) 2024 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
# Subdirs
|
||||
|
||||
# Sources
|
||||
target_sources(${DAWN_TARGET_NAME}
|
||||
PRIVATE
|
||||
textbox.c
|
||||
)
|
27
src/dawn/ui/textbox.c
Normal file
27
src/dawn/ui/textbox.c
Normal file
@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Copyright (c) 2024 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "textbox.h"
|
||||
#include "assert/assert.h"
|
||||
|
||||
textbox_t TEXTBOX;
|
||||
|
||||
void textboxInit() {
|
||||
memset(&TEXTBOX, 0, sizeof(textbox_t));
|
||||
}
|
||||
|
||||
void textboxSetText(const char_t *text) {
|
||||
assertNotNull(text, "Text cannot be NULL.");
|
||||
size_t len = strlen(text);
|
||||
assertTrue(len < TEXTBOX_TEXT_MAX - 1, "Text is too long.");
|
||||
strcpy(TEXTBOX.text, text);
|
||||
TEXTBOX.open = true;
|
||||
}
|
||||
|
||||
bool_t textboxIsOpen() {
|
||||
return TEXTBOX.open;
|
||||
}
|
37
src/dawn/ui/textbox.h
Normal file
37
src/dawn/ui/textbox.h
Normal file
@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Copyright (c) 2024 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "dawn.h"
|
||||
|
||||
#define TEXTBOX_TEXT_MAX 256
|
||||
|
||||
typedef struct {
|
||||
char_t text[TEXTBOX_TEXT_MAX];
|
||||
bool_t open;
|
||||
} textbox_t;
|
||||
|
||||
extern textbox_t TEXTBOX;
|
||||
|
||||
/**
|
||||
* Initializes the textbox.
|
||||
*/
|
||||
void textboxInit();
|
||||
|
||||
/**
|
||||
* Sets the text of the textbox, and opens it.
|
||||
*
|
||||
* @param text Text to set.
|
||||
*/
|
||||
void textboxSetText(const char_t *text);
|
||||
|
||||
/**
|
||||
* Returns whether the textbox is open.
|
||||
*
|
||||
* @return Whether the textbox is open.
|
||||
*/
|
||||
bool_t textboxIsOpen();
|
Reference in New Issue
Block a user