Testing around with asset loading.
This commit is contained in:
@ -27,6 +27,7 @@ void assetManagerInit(assetmanager_t *manager) {
|
|||||||
threadInit(&manager->thread, &_assetManagerThread);
|
threadInit(&manager->thread, &_assetManagerThread);
|
||||||
manager->thread.user = manager;
|
manager->thread.user = manager;
|
||||||
manager->itemCount = 0;
|
manager->itemCount = 0;
|
||||||
|
manager->finished = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void assetManagerStart(assetmanager_t *manager) {
|
void assetManagerStart(assetmanager_t *manager) {
|
||||||
@ -90,6 +91,8 @@ int32_t _assetManagerThread(thread_t *thread) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
manager->finished = assetManagerProgressGet(manager) >= 1.0f;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,6 +126,8 @@ void assetManagerUpdate(assetmanager_t *manager) {
|
|||||||
item->state = ASSET_MANAGER_STATE_SYNC_DONE;
|
item->state = ASSET_MANAGER_STATE_SYNC_DONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
manager->finished = assetManagerProgressGet(manager) >= 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
assetmanageritem_t * assetManagerItemAdd(assetmanager_t *manager) {
|
assetmanageritem_t * assetManagerItemAdd(assetmanager_t *manager) {
|
||||||
|
@ -75,9 +75,9 @@ typedef struct {
|
|||||||
// Manager
|
// Manager
|
||||||
typedef struct {
|
typedef struct {
|
||||||
thread_t thread;
|
thread_t thread;
|
||||||
|
|
||||||
assetmanageritem_t items[ASSET_MANAGER_ITEMS_MAX];
|
assetmanageritem_t items[ASSET_MANAGER_ITEMS_MAX];
|
||||||
uint8_t itemCount;
|
uint8_t itemCount;
|
||||||
|
bool finished;
|
||||||
} assetmanager_t;
|
} assetmanager_t;
|
||||||
|
|
||||||
extern assetmanagerloaderdefinition_t ASSET_MANAGER_LOADERS[];
|
extern assetmanagerloaderdefinition_t ASSET_MANAGER_LOADERS[];
|
||||||
|
@ -23,6 +23,7 @@ typedef struct {
|
|||||||
pokercharacterinitmethod_t *init;
|
pokercharacterinitmethod_t *init;
|
||||||
} pokercharacterdefinition_t;
|
} pokercharacterdefinition_t;
|
||||||
|
|
||||||
|
#define POKER_CHARACTER_DEFINITIONS_COUNT 0x05
|
||||||
extern pokercharacterdefinition_t POKER_CHARACTER_DEFINITIONS[];
|
extern pokercharacterdefinition_t POKER_CHARACTER_DEFINITIONS[];
|
||||||
|
|
||||||
void pokerCharacterInit(vncharacter_t *crctr, texture_t *txtr, uint8_t i);
|
void pokerCharacterInit(vncharacter_t *crctr, texture_t *txtr, uint8_t i);
|
@ -8,29 +8,40 @@
|
|||||||
#include "game.h"
|
#include "game.h"
|
||||||
|
|
||||||
bool pokerGameInit(pokergame_t *game) {
|
bool pokerGameInit(pokergame_t *game) {
|
||||||
// Load the Assets.
|
// Begin to load the assets.
|
||||||
pokerGameAssetsInit(&game->assets);
|
pokerGameAssetsInit(&game->assets);
|
||||||
|
loadingSceneInit(&game->loadingScene, &game->assets.manager);
|
||||||
// Initialize the Visual Novel Engine.
|
loadingSceneStart(&game->loadingScene);
|
||||||
vnSceneInit(&game->scene,
|
|
||||||
&game->assets.font,
|
|
||||||
&game->assets.testTexture
|
|
||||||
);
|
|
||||||
|
|
||||||
// Initialize the world
|
|
||||||
pokerWorldInit(&game->world, &game->scene, &game->assets);
|
|
||||||
|
|
||||||
// Initialize the UI.
|
|
||||||
pokerUiInit(&game->ui);
|
|
||||||
|
|
||||||
// Add the first action, the game action, and then start the action queue.
|
|
||||||
pokerGameActionStartAdd(game);
|
|
||||||
queueNext(&game->scene.conversation.actionQueue);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pokerGameUpdate(pokergame_t *game) {
|
void pokerGameUpdate(pokergame_t *game) {
|
||||||
|
bool t;
|
||||||
|
if(!game->loadingScene.manager->finished) {
|
||||||
|
t = loadingSceneUpdate(&game->loadingScene);
|
||||||
|
if(t) {
|
||||||
|
// Initialize the Visual Novel Engine.
|
||||||
|
vnSceneInit(&game->scene,
|
||||||
|
&game->assets.font,
|
||||||
|
&game->assets.testTexture
|
||||||
|
);
|
||||||
|
|
||||||
|
// Initialize the world
|
||||||
|
pokerWorldInit(&game->world, &game->scene, &game->assets);
|
||||||
|
|
||||||
|
// Initialize the UI.
|
||||||
|
pokerUiInit(&game->ui);
|
||||||
|
|
||||||
|
// Add the first action, the game action, and then start the action queue.
|
||||||
|
pokerGameActionStartAdd(game);
|
||||||
|
queueNext(&game->scene.conversation.actionQueue);
|
||||||
|
} else {
|
||||||
|
loadingSceneRender(&game->loadingScene);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Update the VN Engine.
|
// Update the VN Engine.
|
||||||
vnSceneUpdate(&game->scene, &game->engine);
|
vnSceneUpdate(&game->scene, &game->engine);
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "../../vn/vnscene.h"
|
#include "../../vn/vnscene.h"
|
||||||
#include "../../util/array.h"
|
#include "../../util/array.h"
|
||||||
#include "../../engine/thread.h"
|
#include "../../engine/thread.h"
|
||||||
|
#include "../../scenes/loadingscene.h"
|
||||||
#include "pokergame.h"
|
#include "pokergame.h"
|
||||||
#include "pokergameassets.h"
|
#include "pokergameassets.h"
|
||||||
#include "pokerui.h"
|
#include "pokerui.h"
|
||||||
|
@ -7,16 +7,21 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "../../libs.h"
|
#include "../../libs.h"
|
||||||
#include "pokergameassets.h"
|
|
||||||
#include "../../poker/poker.h"
|
#include "../../poker/poker.h"
|
||||||
#include "../../vn/conversation/talk.h"
|
#include "../../vn/conversation/talk.h"
|
||||||
#include "../../vn/vnscene.h"
|
#include "../../vn/vnscene.h"
|
||||||
#include "../../util/array.h"
|
#include "../../util/array.h"
|
||||||
|
#include "../../scenes/loadingscene.h"
|
||||||
|
#include "pokergameassets.h"
|
||||||
#include "pokerui.h"
|
#include "pokerui.h"
|
||||||
#include "pokerworld.h"
|
#include "pokerworld.h"
|
||||||
#include "pokergameaction.h"
|
#include "pokergameaction.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
loadingscene_t loadingScene;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Game Engine Instance */
|
/** Game Engine Instance */
|
||||||
engine_t engine;
|
engine_t engine;
|
||||||
|
|
||||||
|
@ -7,21 +7,38 @@
|
|||||||
#include "pokergameassets.h"
|
#include "pokergameassets.h"
|
||||||
|
|
||||||
bool pokerGameAssetsInit(pokergameassets_t *assets) {
|
bool pokerGameAssetsInit(pokergameassets_t *assets) {
|
||||||
// Load the game's shader
|
uint8_t i;
|
||||||
assetShaderLoad(&assets->shader,
|
assetManagerInit(&assets->manager);
|
||||||
"shaders/textured.vert", "shaders/textured.frag"
|
|
||||||
);
|
|
||||||
|
|
||||||
// Load the game's font
|
|
||||||
assetFontLoad(&assets->font, "fonts/opensans/OpenSans-Bold.ttf");
|
|
||||||
|
|
||||||
// Initialize the language buffer.
|
// Initialize the language buffer.
|
||||||
languageInit(&assets->language, "locale/language/en-US.csv");
|
languageInit(&assets->language, "locale/language/en-US.csv");
|
||||||
|
|
||||||
|
|
||||||
|
assetManagerShaderLoad(&assets->manager, &assets->shader,
|
||||||
|
"shaders/textured.vert", "shaders/textured.frag"
|
||||||
|
);
|
||||||
|
|
||||||
|
assetManagerLoadFont(&assets->manager, &assets->font,
|
||||||
|
"fonts/opensans/OpenSans-Bold.ttf"
|
||||||
|
);
|
||||||
|
|
||||||
// Load the world textures.
|
// Load the world textures.
|
||||||
assetTextureLoad(&assets->testTexture, "textures/test_texture.png");
|
assetManagerLoadTexture(&assets->manager, &assets->testTexture,
|
||||||
assetTextureLoad(&assets->cardTexture, "poker/cards.png");
|
"textures/test_texture.png"
|
||||||
assetTextureLoad(&assets->roomTexture, "poker/pub_skywall.png");
|
);
|
||||||
|
assetManagerLoadTexture(&assets->manager, &assets->cardTexture,
|
||||||
|
"poker/cards.png"
|
||||||
|
);
|
||||||
|
assetManagerLoadTexture(&assets->manager, &assets->roomTexture,
|
||||||
|
"poker/pub_skywall.png"
|
||||||
|
);
|
||||||
|
|
||||||
|
// Load character textures.
|
||||||
|
for(i = 0; i < POKER_CHARACTER_DEFINITIONS_COUNT; i++) {
|
||||||
|
assetManagerLoadTexture(&assets->manager, assets->characterTextures + i,
|
||||||
|
POKER_CHARACTER_DEFINITIONS[i].fileTexture
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -30,10 +47,8 @@ void pokerGameAssetsDispose(pokergameassets_t *assets) {
|
|||||||
// Now we unload in what is essentially the reverse of the above.
|
// Now we unload in what is essentially the reverse of the above.
|
||||||
textureDispose(&assets->roomTexture);
|
textureDispose(&assets->roomTexture);
|
||||||
textureDispose(&assets->testTexture);
|
textureDispose(&assets->testTexture);
|
||||||
|
textureDispose(&assets->cardTexture);
|
||||||
languageDispose(&assets->language);
|
|
||||||
|
|
||||||
fontDispose(&assets->font);
|
fontDispose(&assets->font);
|
||||||
|
|
||||||
shaderDispose(&assets->shader);
|
shaderDispose(&assets->shader);
|
||||||
|
languageDispose(&assets->language);
|
||||||
}
|
}
|
@ -8,6 +8,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "../../libs.h"
|
#include "../../libs.h"
|
||||||
#include "../../file/asset.h"
|
#include "../../file/asset.h"
|
||||||
|
#include "../../file/assetmanager.h"
|
||||||
#include "../../locale/language.h"
|
#include "../../locale/language.h"
|
||||||
#include "../../display/texture.h"
|
#include "../../display/texture.h"
|
||||||
#include "../../vn/vncharacter.h"
|
#include "../../vn/vncharacter.h"
|
||||||
@ -15,6 +16,8 @@
|
|||||||
#include "characters/characters.h"
|
#include "characters/characters.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
assetmanager_t manager;
|
||||||
|
|
||||||
font_t font;
|
font_t font;
|
||||||
shader_t shader;
|
shader_t shader;
|
||||||
language_t language;
|
language_t language;
|
||||||
@ -23,7 +26,7 @@ typedef struct {
|
|||||||
texture_t roomTexture;
|
texture_t roomTexture;
|
||||||
texture_t cardTexture;
|
texture_t cardTexture;
|
||||||
|
|
||||||
texture_t characterTextures[POKER_PLAYER_COUNT_MAX];
|
texture_t characterTextures[POKER_CHARACTER_DEFINITIONS_COUNT];
|
||||||
} pokergameassets_t;
|
} pokergameassets_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,7 +26,6 @@ void pokerWorldInit(
|
|||||||
for(i = 0x00; i < POKER_PLAYER_COUNT_MAX; i++) {
|
for(i = 0x00; i < POKER_PLAYER_COUNT_MAX; i++) {
|
||||||
character = scene->characters + scene->characterCount;
|
character = scene->characters + scene->characterCount;
|
||||||
texture = assets->characterTextures + i;
|
texture = assets->characterTextures + i;
|
||||||
assetTextureLoad(texture, POKER_CHARACTER_DEFINITIONS[i].fileTexture);
|
|
||||||
pokerCharacterInit(character, texture, i);
|
pokerCharacterInit(character, texture, i);
|
||||||
pokerWorldSitCharacter(character, POKER_WORLD_SEAT_FOR_PLAYER(i));
|
pokerWorldSitCharacter(character, POKER_WORLD_SEAT_FOR_PLAYER(i));
|
||||||
scene->characterCount++;
|
scene->characterCount++;
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
|
|
||||||
|
|
||||||
bool sandboxGameInit(sandboxgame_t *game) {
|
bool sandboxGameInit(sandboxgame_t *game) {
|
||||||
quadInit(&game->quad, 0, 0,0,0,0, 500,500,1,1);
|
quadInit(&game->quad, 0, 0,0,0,0, 500,500,1,1);
|
||||||
|
|
||||||
|
32
src/scenes/loadingscene.c
Normal file
32
src/scenes/loadingscene.c
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2021 Dominic Masters
|
||||||
|
*
|
||||||
|
* This software is released under the MIT License.
|
||||||
|
* https://opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "loadingscene.h"
|
||||||
|
|
||||||
|
void loadingSceneInit(
|
||||||
|
loadingscene_t *scene,
|
||||||
|
assetmanager_t *assetManager
|
||||||
|
) {
|
||||||
|
scene->manager = assetManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
void loadingSceneStart(loadingscene_t *scene) {
|
||||||
|
assetManagerStart(scene->manager);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool loadingSceneUpdate(loadingscene_t *scene) {
|
||||||
|
assetManagerUpdate(scene->manager);
|
||||||
|
return scene->manager->finished;
|
||||||
|
}
|
||||||
|
|
||||||
|
void loadingSceneRender(loadingscene_t *scene) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void loadingSceneDispose(loadingscene_t *scene) {
|
||||||
|
|
||||||
|
}
|
26
src/scenes/loadingscene.h
Normal file
26
src/scenes/loadingscene.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2021 Dominic Masters
|
||||||
|
*
|
||||||
|
* This software is released under the MIT License.
|
||||||
|
* https://opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "../file/assetmanager.h"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
assetmanager_t *manager;
|
||||||
|
} loadingscene_t;
|
||||||
|
|
||||||
|
void loadingSceneInit(
|
||||||
|
loadingscene_t *scene,
|
||||||
|
assetmanager_t *assetManager
|
||||||
|
);
|
||||||
|
|
||||||
|
void loadingSceneStart(loadingscene_t *scene);
|
||||||
|
|
||||||
|
bool loadingSceneUpdate(loadingscene_t *scene);
|
||||||
|
|
||||||
|
void loadingSceneRender(loadingscene_t *scene);
|
||||||
|
|
||||||
|
void loadingSceneDispose(loadingscene_t *scene);
|
Reference in New Issue
Block a user