Compare commits
18 Commits
841ff371da
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| fb6f902f28 | |||
| b060784bb7 | |||
| 9a2e03b146 | |||
| b81296a4f2 | |||
| 554d6198fd | |||
| 70b5277f87 | |||
| 3375f56492 | |||
| 03ee76e0a5 | |||
| a7f11f8842 | |||
| 3cec6a5541 | |||
| 1f0a1d4f47 | |||
| 2d230ecd2e | |||
| 2a58c3b24b | |||
| 475fb5a847 | |||
| 06d2cbdc12 | |||
| 6ed9a15177 | |||
|
|
a9121b58a0 | ||
|
|
83ba5699ac |
41
.github/workflows/build.yml
vendored
41
.github/workflows/build.yml
vendored
@@ -1,41 +0,0 @@
|
|||||||
name: Build
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
pull_request:
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
name: Build Game
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout Project
|
|
||||||
uses: actions/checkout@v6
|
|
||||||
with:
|
|
||||||
submodules: "recursive"
|
|
||||||
|
|
||||||
- name: "Install dependencies"
|
|
||||||
run: |
|
|
||||||
sudo apt-get update -y
|
|
||||||
sudo apt-get install -y \
|
|
||||||
gnome-desktop-testing libasound2-dev libpulse-dev libaudio-dev libjack-dev libsndio-dev \
|
|
||||||
libusb-1.0-0-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev \
|
|
||||||
libxss-dev libxtst-dev libwayland-dev libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev \
|
|
||||||
libgles2-mesa-dev libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev fcitx-libs-dev
|
|
||||||
|
|
||||||
- name: CMake Build
|
|
||||||
run: |
|
|
||||||
mkdir build
|
|
||||||
cmake -S . -B ./build -DSDL_UNIX_CONSOLE_BUILD=ON
|
|
||||||
make -C build
|
|
||||||
|
|
||||||
- name: Upload Artifact
|
|
||||||
uses: actions/upload-artifact@v6
|
|
||||||
with:
|
|
||||||
name: linux-build
|
|
||||||
path: build/snivy
|
|
||||||
|
|
||||||
@@ -109,10 +109,12 @@ set (TINYXML2_SOURCES ${TINYXML2_DIR}/tinyxml2.cpp)
|
|||||||
file(GLOB PROJECT_SRC CONFIGURE_DEPENDS
|
file(GLOB PROJECT_SRC CONFIGURE_DEPENDS
|
||||||
include/*.cpp
|
include/*.cpp
|
||||||
src/*.cpp
|
src/*.cpp
|
||||||
|
src/render/*.cpp
|
||||||
src/resource/*.cpp
|
src/resource/*.cpp
|
||||||
src/resource/xml/*.cpp
|
src/resource/xml/*.cpp
|
||||||
src/state/*.cpp
|
src/state/*.cpp
|
||||||
src/state/main/*.cpp
|
src/state/play/*.cpp
|
||||||
|
src/state/play/arcade/*.cpp
|
||||||
src/state/select/*.cpp
|
src/state/select/*.cpp
|
||||||
src/entity/*.cpp
|
src/entity/*.cpp
|
||||||
src/window/*.cpp
|
src/window/*.cpp
|
||||||
@@ -199,7 +201,7 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(PROJECT_RESOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/resources")
|
set(PROJECT_RESOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/resources")
|
||||||
set(PROJECT_RESOURCES_BINARY_DIR "$<TARGET_FILE_DIR:${PROJECT_NAME}>/resources")
|
set(PROJECT_RESOURCES_BINARY_DIR "${CMAKE_BINARY_DIR}/bin/$<CONFIG>/resources")
|
||||||
if(EXISTS "${PROJECT_RESOURCES_DIR}")
|
if(EXISTS "${PROJECT_RESOURCES_DIR}")
|
||||||
file(GLOB_RECURSE PROJECT_RESOURCE_FILES CONFIGURE_DEPENDS
|
file(GLOB_RECURSE PROJECT_RESOURCE_FILES CONFIGURE_DEPENDS
|
||||||
"${PROJECT_RESOURCES_DIR}/*")
|
"${PROJECT_RESOURCES_DIR}/*")
|
||||||
@@ -209,7 +211,6 @@ if(EXISTS "${PROJECT_RESOURCES_DIR}")
|
|||||||
-DSRC_DIR="${PROJECT_RESOURCES_DIR}"
|
-DSRC_DIR="${PROJECT_RESOURCES_DIR}"
|
||||||
-DDST_DIR="${PROJECT_RESOURCES_BINARY_DIR}"
|
-DDST_DIR="${PROJECT_RESOURCES_BINARY_DIR}"
|
||||||
-P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/copy_resources.cmake"
|
-P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/copy_resources.cmake"
|
||||||
WORKING_DIRECTORY "$<TARGET_FILE_DIR:${PROJECT_NAME}>"
|
|
||||||
DEPENDS ${PROJECT_RESOURCE_FILES}
|
DEPENDS ${PROJECT_RESOURCE_FILES}
|
||||||
COMMENT "Copying resources directory")
|
COMMENT "Copying resources directory")
|
||||||
add_dependencies(${PROJECT_NAME} copy_resources)
|
add_dependencies(${PROJECT_NAME} copy_resources)
|
||||||
@@ -259,6 +260,17 @@ else()
|
|||||||
target_link_libraries(${PROJECT_NAME} PRIVATE OpenGL::GL)
|
target_link_libraries(${PROJECT_NAME} PRIVATE OpenGL::GL)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(WIN32 AND NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
|
||||||
|
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND}
|
||||||
|
-DBIN_ROOT="${CMAKE_BINARY_DIR}/bin"
|
||||||
|
-DTARGET_DIR="$<TARGET_FILE_DIR:${PROJECT_NAME}>"
|
||||||
|
-DEXE_FILE="$<TARGET_FILE_NAME:${PROJECT_NAME}>"
|
||||||
|
-DPACKAGE_NAME="snivy-win32"
|
||||||
|
-P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/create_windows_zip.cmake"
|
||||||
|
COMMENT "Creating snivy-win32 package")
|
||||||
|
endif()
|
||||||
|
|
||||||
message(STATUS "System: ${CMAKE_SYSTEM_NAME}")
|
message(STATUS "System: ${CMAKE_SYSTEM_NAME}")
|
||||||
message(STATUS "Project: ${PROJECT_NAME}")
|
message(STATUS "Project: ${PROJECT_NAME}")
|
||||||
message(STATUS "Compiler: ${CMAKE_CXX_COMPILER}")
|
message(STATUS "Compiler: ${CMAKE_CXX_COMPILER}")
|
||||||
|
|||||||
602
MODDING.md
Normal file
602
MODDING.md
Normal file
@@ -0,0 +1,602 @@
|
|||||||
|
# Modding Feed Snivy
|
||||||
|
|
||||||
|
Want to add characters or modify existing ones or mod Feed Snivy in general or otherwise want to know how the game works? Here's how.
|
||||||
|
|
||||||
|
# Animation Format
|
||||||
|
|
||||||
|
Feed Snivy uses a semi-proprietary format called ".anm2" for tweened character animations, sourced from a spritesheet. This file format comes from the game _The Binding of Isaac: Rebirth_ (a game I mod on my own time) for animations.
|
||||||
|
|
||||||
|
You can either use my own animation editor for that game and this one (recommended), [Anm2Ed](https://github.com/ShweetsStuff/anm2ed), or if you have that game on Steam, you can find that game's own proprietary animation editor in that game's Steam folder and then in tools/IsaacAnimationEditor. I can't guarantee the stability or perfect efficacy of either, but Anm2Ed has crash mitigations and autosave (but of course, save often, for whatever you do).
|
||||||
|
|
||||||
|
Anm2Ed has slightly more extensions to the base format; in particular, something called "Regions", which allows you to set spritesheet regions (areas in the spritesheet that can be repurposed) to quickly reference in animations; previously, one would have to manually create a perfectly spaced spritesheet and then manually set values; this is no longer the case, so using "Regions" is recommended. For the leanest files, in Anm2Ed, go to Settings -> Configure -> File -> Compatibility, and set it to "Anm2Ed Limited".
|
||||||
|
|
||||||
|
My process for making characters is that they're typically comprised of many "cells" (small graphics). I make these cells their own file, and then in the editor, I drag them onto "Spritesheets" and then right click -> merge them, with the "Make Spritesheet Regions" option enabled. Then, right click -> Pack on a spritesheet to optimize it all nice for one big spritesheet atlas with everything in one place. It won't produce a very comprehensible spritesheet, but it works just fine (not my problem). Make sure to save the spritesheets you're using once you're done. You can sort regions around by clicking, holding and moving them around.
|
||||||
|
|
||||||
|
If you'd like a quick primer on how to use either program, check either of [these](https://www.youtube.com/watch?v=qU_GMo2l7NY) [videos](https://www.youtube.com/watch?v=QiXVM6Gwzlw) out. Much of the information is interchangeable between the programs, though both are a little out of date on their current version.
|
||||||
|
|
||||||
|
For each "stage" of the character (graphical change), an animation equivalent will be expected. Stages are zero-indexed in this context; so the first stage would be 0. If you have an idle animation and want that for the first, starting stage, you'd need to name the animation "Idle0", for example, and then reference that in character.xml (more on that later). Don't manually input the number for the animation in any file, just put in the first part, "Idle"; the game will handle which stage-animation plays when.
|
||||||
|
|
||||||
|
Know that despite Anm2Ed supporting sounds for animations, don't expect these to work in context based on names; use the .xml sound attributes when applicable. You can add sounds for fluff, though.
|
||||||
|
|
||||||
|
# Resources
|
||||||
|
|
||||||
|
There's two folders inside resources; "characters" and "font".
|
||||||
|
|
||||||
|
"font" is just a font containing the font used in the selection screen. That's literally it. This technically isn't needed; Dear ImGui has its own font that will be used if this font is missing.
|
||||||
|
|
||||||
|
EVERYTHING ELSE is stored inside bespoke character archives (.zips) in the "characters" folder. This has all data associated with characters. Think of characters more as tailored game experiences rather than literally being just the characters. Not only is there the character graphics, but backgrounds, items, parameters, etc. These are intensely customizable to suit whatever experience you'd like (within the confines of the engine, of course).
|
||||||
|
|
||||||
|
Feed Snivy uses a collection of [XML](https://en.wikipedia.org/wiki/XML) files to parse data; make sure to brush up on the format. The engine can expect six files in the archive's root:
|
||||||
|
|
||||||
|
- areas.xml
|
||||||
|
- character.xml
|
||||||
|
- cursor.xml
|
||||||
|
- dialogue.xml
|
||||||
|
- items.xml
|
||||||
|
- menu.xml
|
||||||
|
- play.xml
|
||||||
|
|
||||||
|
(dialogue.xml may or may not be optional; but in future updates I'll make sure of it, for dialogueless characters).
|
||||||
|
|
||||||
|
If you're making your own character, your best bet would probably be just to copy the Snivy character and edit it based on your needs, just as a helpful start.
|
||||||
|
|
||||||
|
# Character
|
||||||
|
|
||||||
|
## areas.xml
|
||||||
|
"Areas" refers to the backgrounds of the game. I'd planned for the game to dynamically switch areas based on stage (in case you want a character to become a blob that grows bigger than a city or whatever) but this isn't implemented. I'd just have one entry in here for the game's background.
|
||||||
|
|
||||||
|
### Areas
|
||||||
|
#### TextureRootPath (path)
|
||||||
|
Working folder/directory of textures the areas will use.
|
||||||
|
|
||||||
|
#### Area
|
||||||
|
#### Texture (path)
|
||||||
|
The file path of the area's texture (background).
|
||||||
|
#### Gravity (float)
|
||||||
|
Gravity the area has; applies to items' velocities per tick.
|
||||||
|
#### Friction (float)
|
||||||
|
Friction of the area; applies to items' velocities when grounded or hitting walls.
|
||||||
|
#### AirResistance (float)
|
||||||
|
Air resistance of the area; applies to items' velocities when airborne.
|
||||||
|
|
||||||
|
## character.xml
|
||||||
|
This is the main character file where much of the functionality is stored.
|
||||||
|
|
||||||
|
### Character
|
||||||
|
#### Name (string)
|
||||||
|
Name of the character; will appear in dialogue, stats, etc.
|
||||||
|
#### TextureRootPath (path)
|
||||||
|
Working folder/directory of where used textures will be contained within.
|
||||||
|
#### SoundRootPath (path)
|
||||||
|
Working folder/directory of where used sounds will be contained within.
|
||||||
|
#### Render (path)
|
||||||
|
Texture for the character's "render" (i.e., a typical full-body display), will show in the Select screen.
|
||||||
|
#### Portrait (path)
|
||||||
|
Texture for the character's "portrait" (i.e., a cropped profile view), will show in the Select screen.
|
||||||
|
#### Anm2 (path)
|
||||||
|
Character's "anm2" file (uses TextureRootPath); should have all the character's animations.
|
||||||
|
#### Description (string)
|
||||||
|
A general description of the character; will show in the Select screen.
|
||||||
|
#### Author (string)
|
||||||
|
The author of the character.
|
||||||
|
#### Weight (float, kilograms)
|
||||||
|
The character's starting weight, in kilograms.
|
||||||
|
#### Capacity (float, calories)
|
||||||
|
The character's starting capacity, in calories.
|
||||||
|
#### CapacityMin (float, calories)
|
||||||
|
The character's minimum capacity, in calories.
|
||||||
|
#### CapacityMax (float, calories)
|
||||||
|
The character's maximum capacity, in calories. Know that max capacity is determined by Capacity * CapacityMaxMultiplier; this determines the max of the "base" capacity.
|
||||||
|
#### CapacityMaxMultiplier (float)
|
||||||
|
Determines the effective max capacity; will be capacity times this number.
|
||||||
|
#### CapacityIfOverStuffedOnDigestBonus (float, percent)
|
||||||
|
When a character is over stuffed (i.e., over base capacity), the character will an additional capacity when digesting based on how overstuffed they are, based on how many calories over the base capacity.
|
||||||
|
#### CaloriesToKilogram (float)
|
||||||
|
Determines how many calories become a kilogram (1 cal -> X kg).
|
||||||
|
#### DigestionRate (float, percent/tick)
|
||||||
|
The base digestion rate, in percent per tick (60 ticks per second).
|
||||||
|
#### DigestionRateMin (float, percent/tick)
|
||||||
|
The minimum digestion rate for the character, in percent per tick.
|
||||||
|
#### DigestionRateMax (float, percent/tick)
|
||||||
|
The maximum digestion rate for the character, in percent per tick.
|
||||||
|
#### DigestionTimerMax (int, ticks)
|
||||||
|
When digesting, the digestion bar will count down, and then when it hits 0, the current calories will be digested. This determines how long this takes, in ticks.
|
||||||
|
#### EatSpeed (float)
|
||||||
|
A multiplier that speeds/slows down the eating animation, at base.
|
||||||
|
#### EatSpeedMin (float)
|
||||||
|
Determines the minimum eating speed multiplier.
|
||||||
|
#### EatSpeedMax (float)
|
||||||
|
Determines the maximum eating speed multiplier.
|
||||||
|
#### GurgleChance (float, percent)
|
||||||
|
Determines how often the character will gurgle (see the Gurgle sounds later) per tick.
|
||||||
|
#### GurgleCapacityMultiplier (float)
|
||||||
|
Per the character's capacity, multiplies the character's gurgle chance based on the percent of capacity filled (based on max capacity). Higher capacity = higher gurgle chance, using this number at maximum.
|
||||||
|
#### DialoguePoolID (string)
|
||||||
|
Determines the character's base dialogue options (for the "How are you feeling?" option in Chat). This is effectively "Stage 1"'s dialogue; each stage should have its own dialogue pool (see later). Also see dialogue.xml for how "Pools" work.
|
||||||
|
### AlternateSpritesheet
|
||||||
|
Determines the alternate spritesheet of the character, if applicable (in Pokemon terms, the "shiny").
|
||||||
|
#### Texture (path)
|
||||||
|
The alternate spritesheet texture; uses TextureRootPath.
|
||||||
|
#### Sound (path)
|
||||||
|
The sound that will play when the spritesheet is set to alternate (either on new game, or with an item that has IsToggleSpritesheet; see items.xml); uses SoundRootPath.
|
||||||
|
#### ID (int)
|
||||||
|
ID of spritesheet that the alternate spritesheet will replace in the character's .anm2.
|
||||||
|
#### ChanceOnNewGame (float, percent)
|
||||||
|
Chance of rolling for the alternate spritesheet on starting a new game, in percent.
|
||||||
|
### Stages
|
||||||
|
A "stage" represents each visual change of the character as the weight increases. By default, there's always one stage; adding more here will add additional stages.
|
||||||
|
#### Threshold (float, kilograms)
|
||||||
|
The weight threshold to reach this stage, in kilograms.
|
||||||
|
#### DialoguePoolID (string)
|
||||||
|
Determines the stage's dialogue options (for the "How are you feeling?" option in Chat). Also see dialogue.xml for how "Pools" work.
|
||||||
|
### Animations
|
||||||
|
The character's animations. Know that a lot of character animations are typically easily played/activated through Dialogue; this is just for animations that aren't reliant on that system. Know that _these animations should just be the base name_; all animations are expected to have a stage number after them, so don't include the number for these.
|
||||||
|
### Start
|
||||||
|
The animation name that will first play when starting a new game; used for like a character's introduction.
|
||||||
|
### Idle
|
||||||
|
The idle animation that the character will regularly return to.
|
||||||
|
### IdleFull
|
||||||
|
When over capacity, this idle animation will be used instead.
|
||||||
|
### StageUp
|
||||||
|
When going to a new stage after digestion and going over a stage's threshold, this animation will play.
|
||||||
|
#### Animation
|
||||||
|
The name of the animation to be used for each of these.
|
||||||
|
### Overrides
|
||||||
|
"Overrides" are the term I use for when some animations will be tweaked by the game engine for effect (blinking and talking being the ones used). There are two elements; "Talk" and "Blink" for this. Typically, how this is handled is that each animation with have an invisible blinking/talking layer (just the graphic that blinks), which will change when called for. Again, review the .anm2 format for what a "layer" is. All that's sourced is just the spritesheet crop in these cases; so don't worry about how the blink/talk layers are set up.
|
||||||
|
### Override
|
||||||
|
#### LayerSource (string)
|
||||||
|
The layer in the animation which will be sourced for the override.
|
||||||
|
#### LayerDestination (string)
|
||||||
|
The layer in the animation which the source will be applied to.
|
||||||
|
### EatAreas
|
||||||
|
An "eat area" is where the food should be dragged to. I'm pretty much expecting this to only be a mouth for most characters but hey maybe you want the character to also eat through their butt or something. Again, not something that's well-developed at the moment.
|
||||||
|
### EatArea
|
||||||
|
#### Null (string)
|
||||||
|
The null area in the animation where food will be checked for. Again, review the .anm2 format.
|
||||||
|
#### Animation (string)
|
||||||
|
The animation that will play when food is dragged to it.
|
||||||
|
#### Event (string)
|
||||||
|
The event that will be checked for, detrermining the time the food is actually eaten/chewed. Again, review the .anm2 format.
|
||||||
|
### ExpandAreas
|
||||||
|
The areas which will expand based on capacity percent; usually a stomach. This adds additional scale onto the layer of an animation. This also can scale a null as well.
|
||||||
|
ExpandAreas are presently hardcoded to scale with both capacity and weight at a 50/50 ratio; this could be changed in the future for custom ratios.
|
||||||
|
#### ExpandArea
|
||||||
|
#### Layer (string)
|
||||||
|
The layer of the animation that will expand.
|
||||||
|
#### Null (string)
|
||||||
|
The null of the animation that will expand.
|
||||||
|
#### ScaleAdd (float, percent)
|
||||||
|
The scale that will be added at maximum. Know that scale is a percent; a {100, 100} scale is the default and is the normal scale of an animation.
|
||||||
|
### InteractAreas
|
||||||
|
The areas on a character which can be interacted with; usually for belly rubs, kisses, etc.
|
||||||
|
### InteractArea
|
||||||
|
#### Type ("Rub", "Kiss", "Smack")
|
||||||
|
Three types are presently hard-coded in, but this is kind of hacky and custom support for different interactions may later be added. The cursor will need to be set from the "Tools" in order for each interact area to be activated.
|
||||||
|
#### Null (string)
|
||||||
|
The null in which the interact area can be triggered. Again, review the .anm2 format.
|
||||||
|
#### Animation (string)
|
||||||
|
The animation that will play when the interact area is activated (hovering and clicking).
|
||||||
|
#### AnimationFull (string)
|
||||||
|
The above, but when character is full.
|
||||||
|
#### AnimationCursorHover (string)
|
||||||
|
The animation the cursor will play when hovering over the interact area.
|
||||||
|
#### AnimationCursorActive (string)
|
||||||
|
The animation the cursor will play when holding down click over the interact area.
|
||||||
|
#### DialoguePoolID (string)
|
||||||
|
The dialogue pool which will be drawn from when activating an interact area (see dialogue.xml).
|
||||||
|
### Sound
|
||||||
|
An interact area can play multiple sounds when interacting; add additional Sound elements to achieve this. Don't worry about repeatedly-loaded sounds; the game will cache them beforehand for efficiency.
|
||||||
|
#### Path (path)
|
||||||
|
The path of the sound being used.
|
||||||
|
### Sounds
|
||||||
|
Sounds that play in some contexts.
|
||||||
|
### Digest
|
||||||
|
Sounds that will play when the character begins digesting (digestion bar full).
|
||||||
|
### Gurgle
|
||||||
|
Ambient sounds that will play randomly based on capacity; see GurgleChance and GurgleCapacityMultiplier above.
|
||||||
|
#### Sound (path)
|
||||||
|
The path of the sound for the specific sound type.
|
||||||
|
|
||||||
|
## cursor.xml
|
||||||
|
Determines the cursor appearance and behavior.
|
||||||
|
### TextureRootPath (path)
|
||||||
|
Working folder/directory of textures the cursor will use.
|
||||||
|
#### SoundRootPath (path)
|
||||||
|
Working folder/directory of sounds the cursor will use.
|
||||||
|
#### Anm2 (path)
|
||||||
|
The anm2 file the cursor will use (depends on TextureRootPath).
|
||||||
|
### Animations
|
||||||
|
### Idle
|
||||||
|
The cursor's default idle animation.
|
||||||
|
### Hover
|
||||||
|
The cursor's hover animation, when hovering over an item.
|
||||||
|
### Grab
|
||||||
|
The cursor's grab animation, when grabbing an item.
|
||||||
|
### Pan
|
||||||
|
The cursor's pan animation, when panning with middle mouse button.
|
||||||
|
### Zoom
|
||||||
|
The cursor's zoom animation, when zooming in/out with the mouse wheel.
|
||||||
|
### Return
|
||||||
|
The cursor's return animation, when holding right click to return an item to the inventory (or to dispose of it if chewed.)
|
||||||
|
#### Animation (string)
|
||||||
|
The animation the cursor will use in these contexts.
|
||||||
|
### Sounds
|
||||||
|
Know that multiple of these sounds can be defined for each context.
|
||||||
|
### Grab
|
||||||
|
The sound that will play when grabbing an item.
|
||||||
|
### Release
|
||||||
|
The sound that will play when releasing an item.
|
||||||
|
### Throw
|
||||||
|
The sound that will play when throwing an item (releasing when dragging quickly).
|
||||||
|
#### Sound (path)
|
||||||
|
The path of the sound for these respective contexts.
|
||||||
|
|
||||||
|
## dialogue.xml
|
||||||
|
The collection of character dialogue; likely the biggest file, depending on your needs.
|
||||||
|
### Dialogue
|
||||||
|
### Entries
|
||||||
|
### Entry
|
||||||
|
Each bit of dialogue is referred to as an "entry".
|
||||||
|
#### ID (string)
|
||||||
|
Name for the entry. Other entries will rely on this for dialogue chains.
|
||||||
|
#### Next (string)
|
||||||
|
The ID of the entry that will follow after this one. If no Next entry, the text will not continue. Make sure to connect these.
|
||||||
|
#### Text (string)
|
||||||
|
The actual dialogue content of the entry. Should support Unicode, provided the font contains the characters.
|
||||||
|
#### Animation (string)
|
||||||
|
A character animation that will play at the beginning of the dialogue. This may be expanded into the future to allow animations to play dynamically per dialogue index. Again, make sure it's just the base name for the animation, no stage numbers.
|
||||||
|
### Choice
|
||||||
|
Dialogue can be branching; simply added "Choice" elements into the Entry element.
|
||||||
|
#### Next (string)
|
||||||
|
The dialogue the choice will lead to.
|
||||||
|
#### Text (string)
|
||||||
|
The text of the choice; will appear as a series of buttons in the text window.
|
||||||
|
### Pools
|
||||||
|
A "pool" of dialogue refers to a collection of entries that can be randomly picked in some contexts.
|
||||||
|
### Pool
|
||||||
|
#### ID (string)
|
||||||
|
The name of the dialogue pool; can be referenced elsewhere.
|
||||||
|
### PoolEntry
|
||||||
|
### ID (string)
|
||||||
|
The name of the entry; to be added to the pool.
|
||||||
|
|
||||||
|
### Start
|
||||||
|
This dialogue will play upon a new game, once its animation has concluded.
|
||||||
|
#### Animation (string)
|
||||||
|
The name of the animation that will be played.
|
||||||
|
#### ID (string)
|
||||||
|
The name of the entry that will be played.
|
||||||
|
### End
|
||||||
|
The dialogue that will play upon completion of the game (character hitting max stage).
|
||||||
|
#### ID (string)
|
||||||
|
The name of the entry that will be played.
|
||||||
|
### Help
|
||||||
|
The dialogue that will be play when the player presses the "Help" button in "Chat".
|
||||||
|
#### ID (string)
|
||||||
|
The name of the entry that will be played.
|
||||||
|
|
||||||
|
### StageUp
|
||||||
|
Dialogue that will play after a character undergoes a stage up.
|
||||||
|
#### PoolID (string)
|
||||||
|
The name of the pool that entries will be drawn from.
|
||||||
|
### Random
|
||||||
|
The dialogue that will be play when the player presses the "Let's chat!" button in "Chat".
|
||||||
|
#### PoolID (string)
|
||||||
|
The name of the pool that entries will be drawn from.
|
||||||
|
### Feed
|
||||||
|
The dialogue that will be play when the user begins holding a food item.
|
||||||
|
#### PoolID (string)
|
||||||
|
The name of the pool that entries will be drawn from.
|
||||||
|
### FeedFull
|
||||||
|
The dialogue that will be play when the user begins holding a food item, when the character is over capacity.
|
||||||
|
#### PoolID (string)
|
||||||
|
The name of the pool that entries will be drawn from.
|
||||||
|
### Eat
|
||||||
|
The dialogue that will be play after the character finishes a food item.
|
||||||
|
#### PoolID (string)
|
||||||
|
The name of the pool that entries will be drawn from.
|
||||||
|
### EatFull
|
||||||
|
The dialogue that will be play after the character finishes a food item, when the character is over capacity.
|
||||||
|
#### PoolID (string)
|
||||||
|
The name of the pool that entries will be drawn from.
|
||||||
|
### Full
|
||||||
|
The dialogue that will be play when the character is completely full and will deny the user feeding them.
|
||||||
|
#### PoolID (string)
|
||||||
|
The name of the pool that entries will be drawn from.
|
||||||
|
### Throw
|
||||||
|
The dialogue that will be play when the user throws food.
|
||||||
|
#### PoolID (string)
|
||||||
|
The name of the pool that entries will be drawn from.
|
||||||
|
### LowCapacity
|
||||||
|
The dialogue that will be play when the character is presented a food item completely over their maximum capacity.
|
||||||
|
#### PoolID (string)
|
||||||
|
The name of the pool that entries will be drawn from.
|
||||||
|
### Digest
|
||||||
|
The dialogue that will be play when digesting is finished.
|
||||||
|
#### PoolID (string)
|
||||||
|
The name of the pool that entries will be drawn from.
|
||||||
|
### FoodTaken
|
||||||
|
The dialogue that will play when food is removed from the null area during a character's eating animation.
|
||||||
|
#### PoolID (string)
|
||||||
|
The name of the pool that entries will be drawn from.
|
||||||
|
### FoodTakenFull
|
||||||
|
The dialogue that will play when food is removed from the null area during a character's eating animation, when the character is over capacity.
|
||||||
|
#### PoolID (string)
|
||||||
|
The name of the pool that entries will be drawn from.
|
||||||
|
|
||||||
|
## items.xml
|
||||||
|
Has all items and their parameters, alongside additional behavior.
|
||||||
|
|
||||||
|
### ItemSchema
|
||||||
|
#### TextureRootPath (path)
|
||||||
|
Working folder/directory of where used textures will be contained within.
|
||||||
|
#### SoundRootPath (path)
|
||||||
|
Working folder/directory of where used sounds will be contained within.
|
||||||
|
#### BaseAnm2 (path)
|
||||||
|
The base anm2 file that items will use. Items can technically have their own .anm2 and animate accordingly, but I haven't tested this much.
|
||||||
|
### Animations
|
||||||
|
### Chew
|
||||||
|
When items are chewed, play this animation. Items can have chew counts and the animation will adapt accordingly, so be sure to have chew animations for chew counts; 1 chew = Chew1, 2 chew = Chew2, etc.
|
||||||
|
#### Animation (string)
|
||||||
|
The name of the animation. Only the base part ("Chew", usually)
|
||||||
|
### Sounds
|
||||||
|
The various item sounds. Multiple of the same element can be defined to randomly play from a selection.
|
||||||
|
### Bounce
|
||||||
|
The sound that will play when an item is bounced (hitting a floor/wall/ceiling with velocity).
|
||||||
|
#### Sound (path)
|
||||||
|
The path to the sound that will play, based on SoundRootPath.
|
||||||
|
### Dispose
|
||||||
|
The sound that will play when an item is disposed of (when an item has chewed and is right clicked).
|
||||||
|
#### Sound (path)
|
||||||
|
The path to the sound that will play, based on SoundRootPath.
|
||||||
|
### Summon
|
||||||
|
The sound that will play when an item is spawned (clicking on it in inventory).
|
||||||
|
#### Sound (path)
|
||||||
|
The path to the sound that will play, based on SoundRootPath.
|
||||||
|
### Return
|
||||||
|
The sound that will play when an item is returned to inventory (right clicking on it in world).
|
||||||
|
#### Sound (path)
|
||||||
|
The path to the sound that will play, based on SoundRootPath.
|
||||||
|
### Categories
|
||||||
|
The kinds of items present. Will appear in inventory tooltips.
|
||||||
|
### Category
|
||||||
|
#### Name (string)
|
||||||
|
The name of the category.
|
||||||
|
#### IsEdible (bool)
|
||||||
|
Determines if the category of item can be eaten by the character.
|
||||||
|
### Flavors
|
||||||
|
Item flavors (for food). Honestly have no meaning but flavor text at the moment but whatever.
|
||||||
|
### Flavor
|
||||||
|
#### Name (string)
|
||||||
|
Name of the flavor.
|
||||||
|
### Rarities
|
||||||
|
Different rarities of item. Shows in inventory and each can have their own drop chance.
|
||||||
|
### Rarity
|
||||||
|
#### Name (string)
|
||||||
|
Name of the rarity.
|
||||||
|
#### Chance (float, percent)
|
||||||
|
Base chance of finding an item, per winning a play of the "play" game. See play.xml for how this is modified.
|
||||||
|
#### Sound (path)
|
||||||
|
Sound that will play when an item is found in the "play" game.
|
||||||
|
#### IsHidden (bool)
|
||||||
|
If true, items with this rarity will not be previewed in the inventory, unlesss possessed. Assumed false if not present.
|
||||||
|
### Items
|
||||||
|
#### TextureRootPath (path)
|
||||||
|
Working folder/directory of where used item textures will be contained within.
|
||||||
|
#### ChewCount (int)
|
||||||
|
Base chew count for items; will be chewed this many times before being erased.
|
||||||
|
Chew count will determine how many calories/digestion bonus/etc. are given per bite (0 chew = all, 2 chew = divided by 3)
|
||||||
|
#### SpritesheetID (int)
|
||||||
|
Item textures will use this spritesheet ID on the base anm2.
|
||||||
|
#### QuantityMax (int)
|
||||||
|
How many items of a type can be possessed at once.
|
||||||
|
### Item
|
||||||
|
An individual item entry.
|
||||||
|
#### Name (string)
|
||||||
|
The name of the item.
|
||||||
|
#### Texture (path)
|
||||||
|
The texture the item uses; uses TextureRootPath.
|
||||||
|
#### Description (string)
|
||||||
|
Flavor text for the item.
|
||||||
|
#### Category (string)
|
||||||
|
The category the item uses; as defined in Categories.
|
||||||
|
#### Rarity (string)
|
||||||
|
The rarity the item uses; as defined in Rarities.
|
||||||
|
#### Anm2 (path; optional)
|
||||||
|
The custom anm2 the item uses, if needed.
|
||||||
|
#### Flavor (string; optional)
|
||||||
|
The flavor the item uses; as defined in Flavors.
|
||||||
|
#### Calories (float; optional)
|
||||||
|
The amount of calories in an item has (if food).
|
||||||
|
#### DigestionBonus (float, percent; optional)
|
||||||
|
The additional digestion rate in percent the item will give if eaten.
|
||||||
|
#### EatSpeedBonus (float; optional)
|
||||||
|
The additional eat speed multiplier the item will give if eaten.
|
||||||
|
#### Gravity (float; optional)
|
||||||
|
The item's gravity; will use the default gravity if not available.
|
||||||
|
#### ChewCount (int; optional)
|
||||||
|
An item's custom chew count.
|
||||||
|
#### UpgradeID (string; optional)
|
||||||
|
The name of another item that this item will be able to be upgraded to.
|
||||||
|
#### UpgradeCount (int; optional)
|
||||||
|
The amount of this item it will take to upgrade to the upgrade item specified in UpgradeID.
|
||||||
|
#### IsPlayReward (bool; optional)
|
||||||
|
The item will be given out when the reward is hit in play (see play.xml)
|
||||||
|
#### IsToggleSpritesheet (bool; optional)
|
||||||
|
When used in the inventory, will toggle the character's spritesheet (in Pokemon terms, toggling normal/shiny palettes).
|
||||||
|
|
||||||
|
## menu.xml
|
||||||
|
Determines menu and general UI appearance and behavior.
|
||||||
|
|
||||||
|
### MenuSchema
|
||||||
|
#### SoundRootPath (path)
|
||||||
|
Working folder/directory of where used sounds will be contained within.
|
||||||
|
#### FontRootPath (path)
|
||||||
|
Working folder/directory of where used fonts will be contained within.
|
||||||
|
#### Font (path)
|
||||||
|
The font the menu will use, based on FontRootPath.
|
||||||
|
#### Rounding (float)
|
||||||
|
The rounding of corners the UI will use.
|
||||||
|
### Sounds
|
||||||
|
Menu sounds.
|
||||||
|
### Open
|
||||||
|
Will play when opening a sliding menu panel.
|
||||||
|
#### Sound (path)
|
||||||
|
The sound that will play, based on SoundRootPath.
|
||||||
|
### Close
|
||||||
|
Will play when closing a sliding menu panel.
|
||||||
|
#### Sound (path)
|
||||||
|
The sound that will play, based on SoundRootPath.
|
||||||
|
### Hover
|
||||||
|
Will play when hovering over a widget in a menu.
|
||||||
|
#### Sound (path)
|
||||||
|
The sound that will play, based on SoundRootPath.
|
||||||
|
### Select
|
||||||
|
Will play when clicking on a widget in a menu.
|
||||||
|
#### Sound (path)
|
||||||
|
The sound that will play, based on SoundRootPath.
|
||||||
|
### CheatsActivated
|
||||||
|
Sound that will play after entering a special code to activate cheats.
|
||||||
|
#### Sound (path)
|
||||||
|
The sound that will play, based on SoundRootPath.
|
||||||
|
|
||||||
|
## play.xml
|
||||||
|
Determines behavior and appearance of the "Play" minigame.
|
||||||
|
|
||||||
|
### Play
|
||||||
|
#### SoundRootPath (path)
|
||||||
|
Working folder/directory of where used sounds will be contained within.
|
||||||
|
#### RewardScore (int)
|
||||||
|
The play score where a rewarded item will be given (see items.xml)
|
||||||
|
#### RewardScoreBonus (float, percent)
|
||||||
|
Based on the player's score, will add additional bonus to being rewarded items.
|
||||||
|
#### RewardGradeBonus (float, percent)
|
||||||
|
Based on the player's grades for a round of play, will add additional bonus to being rewarded items.
|
||||||
|
#### SpeedMin (float, unit/tick)
|
||||||
|
The beginning/base speed of the bar in the minigame.
|
||||||
|
#### SpeedMax (float, unit/tick)
|
||||||
|
The maximum speed the bar in the minigame can achieve.
|
||||||
|
#### SpeedScoreBonus (float)
|
||||||
|
The additional speed of the bar based on the player's score.
|
||||||
|
#### RangeBase (float)
|
||||||
|
A "range" is each area in the minigame that can be hit. This is the base size of one. Per each grade, it's halved. Range size decreases as minigame progresses.
|
||||||
|
#### RangeMin (float)
|
||||||
|
The minimum size of a range; achievable at high scores.
|
||||||
|
#### RangeScoreBonus (float)
|
||||||
|
Really a negative. The range size will decrease this much per point of score.
|
||||||
|
#### EndTimerMax (int)
|
||||||
|
The period of time between plays of the minigame.
|
||||||
|
#### EndTimerFailureMax (int)
|
||||||
|
When a player fails (no ranges hit), the minigame will pause fo this amount of time, until restarting.
|
||||||
|
### Sounds
|
||||||
|
### Fall
|
||||||
|
The sound that plays when an item falls from being rewarded.
|
||||||
|
#### Sound (path)
|
||||||
|
The sound that will play, based on SoundRootPath.
|
||||||
|
### ScoreLoss
|
||||||
|
The sound that plays when the bar goes over the edge and loops, deducting a point.
|
||||||
|
#### Sound (path)
|
||||||
|
The sound that will play, based on SoundRootPath.
|
||||||
|
### HighScore
|
||||||
|
The sound that plays when the player achieves a high score. Only heard when a high score has been set during the play session.
|
||||||
|
#### Sound (path)
|
||||||
|
The sound that will play, based on SoundRootPath.
|
||||||
|
### HighScoreLoss
|
||||||
|
The sound that plays when the player has achieved a high score, and then fails.
|
||||||
|
#### Sound (path)
|
||||||
|
The sound that will play, based on SoundRootPath.
|
||||||
|
### RewardScore
|
||||||
|
The sound that plays when the player has hit the reward score.
|
||||||
|
#### Sound (path)
|
||||||
|
The sound that will play, based on SoundRootPath.
|
||||||
|
### Grades
|
||||||
|
A "grade" is a rank the player can get. This determines the count of ranges in the minigame; each range corresponds to a grade.
|
||||||
|
### Grade
|
||||||
|
#### Name (string)
|
||||||
|
The name of the grade; will appear when the player hits its respective range in the minigame.
|
||||||
|
#### NamePlural (string)
|
||||||
|
The plural name of the grade; will appear in Stats.
|
||||||
|
#### Value (int)
|
||||||
|
The reward value of the grade, in points.
|
||||||
|
#### Weight (float)
|
||||||
|
The "weight" of the grade; used to determine accuracy score in Stats.
|
||||||
|
#### IsFailure (bool)
|
||||||
|
If the player hits this grade's respective range, will count as failure.
|
||||||
|
#### DialoguePoolID (string; optional)
|
||||||
|
If the player hits this grade, the character will speak dialogue from this pool (see dialogue.xml)
|
||||||
|
#### Sound (path)
|
||||||
|
This sound will play when the grade is hit.
|
||||||
|
|
||||||
|
# Saves
|
||||||
|
|
||||||
|
Outside of resources, Feed Snivy also has a few files it writes outside of the game. You will find these in %AppData%/snivy on Windows and ~/.local/share/snivy on Linux.
|
||||||
|
|
||||||
|
## settings.xml
|
||||||
|
Stores general game settings and configuration; beyond invididual characters.
|
||||||
|
### MeasurementSystem ("Imperial", "Metric")
|
||||||
|
Determines measurement system (kg/lb).
|
||||||
|
### Volume (int, percent)
|
||||||
|
Master volume.
|
||||||
|
### ColorR, ColorG, ColorB (float, 0-1)
|
||||||
|
Red/Green/Blue components of menu color.
|
||||||
|
### WindowX, WindowY (int)
|
||||||
|
Window position.
|
||||||
|
### WindowW/H (int)
|
||||||
|
Window size.
|
||||||
|
|
||||||
|
## *.save
|
||||||
|
Saves are per-character; will be named "[blank].save", stored in "saves" folder, from the name of the character's archive.
|
||||||
|
|
||||||
|
### Save
|
||||||
|
#### IsPostgame (bool)
|
||||||
|
Determines if the game has been completed (character's max stage has been reached); if true, will enable cheats.
|
||||||
|
#### IsAlternateSpritesheet (bool)
|
||||||
|
Determines if the character's spritesheet is using the alternate version (in Pokemon, would be the "shiny" version
|
||||||
|
|
||||||
|
### Character
|
||||||
|
#### Weight (float)
|
||||||
|
Character's current weight, in kilograms.
|
||||||
|
#### Calories (float)
|
||||||
|
Character's current consumed calories.
|
||||||
|
#### Capacity (float)
|
||||||
|
Character's capacity, in calories. Remember, max capacity effectively is capacity * CapacityMaxMultiplier (from character.xml)
|
||||||
|
#### DigestionRate (float, percent)
|
||||||
|
Character's digestion rate in percent, per game tick (game ticks 60 times per second).
|
||||||
|
#### EatSpeed (float)
|
||||||
|
Eat speed multiplier for the character's Eat animation.
|
||||||
|
#### IsDigesting (bool)
|
||||||
|
Determines if character is currently digesting (when the bar is going down)
|
||||||
|
#### DigestionProgress (float, percent)
|
||||||
|
Character's digestion progress. Digestion max is always 100%.
|
||||||
|
#### DigestionTimer (int)
|
||||||
|
When digestion bar is going down, this is the remaining time to 0 (in ticks)
|
||||||
|
#### TotalCaloriesConsumed (float)
|
||||||
|
Total calories consumed by the character, per save file.
|
||||||
|
#### TotalFoodItemsEaten (int)
|
||||||
|
How many food items have been completely consumed by the character, per save file.
|
||||||
|
|
||||||
|
### Play
|
||||||
|
#### TotalPlays (int)
|
||||||
|
However many times the "play" game has been attempted (hitting the bar counts as one "play")
|
||||||
|
#### HighScore (int)
|
||||||
|
Highest score the player has achieved in the "play" game.
|
||||||
|
#### BestCombo (int)
|
||||||
|
Highest combo the player has achieved (how many successful hits the player has gotten in one session)
|
||||||
|
#### Grades
|
||||||
|
Play grades are the ratings the game gives based on where the player hit.
|
||||||
|
##### ID (int)
|
||||||
|
ID of grade being tracked (see play.xml)
|
||||||
|
##### Count (int)
|
||||||
|
How many times the grade has been hit.
|
||||||
|
|
||||||
|
### Inventory
|
||||||
|
Items.
|
||||||
|
#### ID (int)
|
||||||
|
ID of item being tracked (see items.xml)
|
||||||
|
#### Quantity (int)
|
||||||
|
Count of the item.
|
||||||
|
|
||||||
|
|
||||||
|
# Conclusion
|
||||||
|
|
||||||
|
Hopefully this'll give you the resources you need to start making your own characters. If you need any help with this guide, or with clarification on anything, I'm available. Additionally, the game is [licensed as free software](https://github.com/ShweetsStuff/snivy), meaning if you're stuck the code should give you a clue (though I apologize for the lack of comments. Self-documenting code though, am I right? :^) )
|
||||||
@@ -4,15 +4,19 @@ endif()
|
|||||||
|
|
||||||
set(CHARACTERS_DIR "${SRC_DIR}/characters")
|
set(CHARACTERS_DIR "${SRC_DIR}/characters")
|
||||||
set(CHARACTERS_ZIP_SCRIPT "${CHARACTERS_DIR}/zip")
|
set(CHARACTERS_ZIP_SCRIPT "${CHARACTERS_DIR}/zip")
|
||||||
|
set(IS_HOST_WINDOWS FALSE)
|
||||||
|
if(CMAKE_HOST_WIN32)
|
||||||
|
set(IS_HOST_WINDOWS TRUE)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(EXISTS "${CHARACTERS_ZIP_SCRIPT}")
|
if(EXISTS "${CHARACTERS_ZIP_SCRIPT}" AND NOT IS_HOST_WINDOWS)
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND "${CHARACTERS_ZIP_SCRIPT}"
|
COMMAND "${CHARACTERS_ZIP_SCRIPT}"
|
||||||
WORKING_DIRECTORY "${CHARACTERS_DIR}"
|
WORKING_DIRECTORY "${CHARACTERS_DIR}"
|
||||||
RESULT_VARIABLE ZIP_SCRIPT_RESULT
|
RESULT_VARIABLE ZIP_SCRIPT_RESULT
|
||||||
)
|
)
|
||||||
if(NOT ZIP_SCRIPT_RESULT EQUAL 0)
|
if(NOT ZIP_SCRIPT_RESULT EQUAL 0)
|
||||||
message(FATAL_ERROR "Failed running ${CHARACTERS_ZIP_SCRIPT} (exit code ${ZIP_SCRIPT_RESULT})")
|
message(WARNING "Failed running ${CHARACTERS_ZIP_SCRIPT} (exit code ${ZIP_SCRIPT_RESULT}); continuing with existing archives")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -26,6 +30,26 @@ file(COPY "${SRC_DIR}/" DESTINATION "${DST_DIR}"
|
|||||||
# Copy only .zip archives from resources/characters.
|
# Copy only .zip archives from resources/characters.
|
||||||
file(MAKE_DIRECTORY "${DST_DIR}/characters")
|
file(MAKE_DIRECTORY "${DST_DIR}/characters")
|
||||||
file(GLOB CHARACTER_ZIPS "${CHARACTERS_DIR}/*.zip")
|
file(GLOB CHARACTER_ZIPS "${CHARACTERS_DIR}/*.zip")
|
||||||
|
|
||||||
|
if(NOT CHARACTER_ZIPS)
|
||||||
|
file(GLOB CHARACTER_FILES RELATIVE "${CHARACTERS_DIR}" "${CHARACTERS_DIR}/*")
|
||||||
|
list(FILTER CHARACTER_FILES EXCLUDE REGEX "^zip$")
|
||||||
|
list(FILTER CHARACTER_FILES EXCLUDE REGEX ".*\\.zip$")
|
||||||
|
|
||||||
|
if(CHARACTER_FILES)
|
||||||
|
execute_process(
|
||||||
|
COMMAND "${CMAKE_COMMAND}" -E tar cf "snivy.zip" --format=zip ${CHARACTER_FILES}
|
||||||
|
WORKING_DIRECTORY "${CHARACTERS_DIR}"
|
||||||
|
RESULT_VARIABLE ZIP_GENERATE_RESULT
|
||||||
|
)
|
||||||
|
if(NOT ZIP_GENERATE_RESULT EQUAL 0)
|
||||||
|
message(WARNING "Failed generating ${CHARACTERS_DIR}/snivy.zip (exit code ${ZIP_GENERATE_RESULT}); continuing without character zip archives")
|
||||||
|
else()
|
||||||
|
file(GLOB CHARACTER_ZIPS "${CHARACTERS_DIR}/*.zip")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
if(CHARACTER_ZIPS)
|
if(CHARACTER_ZIPS)
|
||||||
file(COPY ${CHARACTER_ZIPS} DESTINATION "${DST_DIR}/characters")
|
file(COPY ${CHARACTER_ZIPS} DESTINATION "${DST_DIR}/characters")
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
47
cmake/create_windows_zip.cmake
Normal file
47
cmake/create_windows_zip.cmake
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
if(NOT DEFINED BIN_ROOT OR BIN_ROOT STREQUAL "")
|
||||||
|
message(FATAL_ERROR "BIN_ROOT is required")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT DEFINED TARGET_DIR OR TARGET_DIR STREQUAL "")
|
||||||
|
message(FATAL_ERROR "TARGET_DIR is required")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT DEFINED EXE_FILE OR EXE_FILE STREQUAL "")
|
||||||
|
message(FATAL_ERROR "EXE_FILE is required")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT DEFINED PACKAGE_NAME OR PACKAGE_NAME STREQUAL "")
|
||||||
|
set(PACKAGE_NAME "snivy-win32")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(EXE_PATH "${TARGET_DIR}/${EXE_FILE}")
|
||||||
|
set(PACKAGE_DIR "${BIN_ROOT}/${PACKAGE_NAME}")
|
||||||
|
set(ARCHIVE_PATH "${BIN_ROOT}/${PACKAGE_NAME}.zip")
|
||||||
|
set(TARGET_RESOURCES_DIR "${TARGET_DIR}/resources")
|
||||||
|
set(BIN_RESOURCES_DIR "${BIN_ROOT}/resources")
|
||||||
|
|
||||||
|
file(MAKE_DIRECTORY "${BIN_ROOT}")
|
||||||
|
file(REMOVE_RECURSE "${PACKAGE_DIR}")
|
||||||
|
file(REMOVE "${ARCHIVE_PATH}")
|
||||||
|
file(MAKE_DIRECTORY "${PACKAGE_DIR}")
|
||||||
|
|
||||||
|
if(EXISTS "${EXE_PATH}")
|
||||||
|
file(COPY "${EXE_PATH}" DESTINATION "${PACKAGE_DIR}")
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Executable not found: ${EXE_PATH}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(EXISTS "${TARGET_RESOURCES_DIR}")
|
||||||
|
file(COPY "${TARGET_RESOURCES_DIR}" DESTINATION "${PACKAGE_DIR}")
|
||||||
|
elseif(EXISTS "${BIN_RESOURCES_DIR}")
|
||||||
|
file(COPY "${BIN_RESOURCES_DIR}" DESTINATION "${PACKAGE_DIR}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND "${CMAKE_COMMAND}" -E tar cf "${PACKAGE_NAME}.zip" --format=zip "${PACKAGE_NAME}"
|
||||||
|
WORKING_DIRECTORY "${BIN_ROOT}"
|
||||||
|
RESULT_VARIABLE ZIP_RESULT
|
||||||
|
)
|
||||||
|
if(NOT ZIP_RESULT EQUAL 0)
|
||||||
|
message(FATAL_ERROR "Failed creating ${ARCHIVE_PATH}")
|
||||||
|
endif()
|
||||||
@@ -240,7 +240,7 @@ namespace game::entity
|
|||||||
auto& index = animationMap.at(queuedPlay.animation);
|
auto& index = animationMap.at(queuedPlay.animation);
|
||||||
if (queuedPlay.isPlayAfterAnimation)
|
if (queuedPlay.isPlayAfterAnimation)
|
||||||
nextQueuedPlay = queuedPlay;
|
nextQueuedPlay = queuedPlay;
|
||||||
else if (index != animationIndex && currentQueuedPlay.isInterruptible)
|
else if ((state == STOPPED || index != animationIndex) && currentQueuedPlay.isInterruptible)
|
||||||
{
|
{
|
||||||
play(queuedPlay.animation, queuedPlay.mode, queuedPlay.time, queuedPlay.speedMultiplier);
|
play(queuedPlay.animation, queuedPlay.mode, queuedPlay.time, queuedPlay.speedMultiplier);
|
||||||
currentQueuedPlay = queuedPlay;
|
currentQueuedPlay = queuedPlay;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
#include "../canvas.hpp"
|
#include "../render/canvas.hpp"
|
||||||
#include "../resource/xml/anm2.hpp"
|
#include "../resource/xml/anm2.hpp"
|
||||||
|
|
||||||
namespace game::entity
|
namespace game::entity
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ namespace game::entity
|
|||||||
isStageUp = false;
|
isStageUp = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextQueuedPlay.empty()) queue_idle_animation();
|
if (nextQueuedPlay.empty() && !isTalking) queue_idle_animation();
|
||||||
}
|
}
|
||||||
|
|
||||||
Actor::tick();
|
Actor::tick();
|
||||||
@@ -335,12 +335,14 @@ namespace game::entity
|
|||||||
|
|
||||||
void Character::queue_play(QueuedPlay play)
|
void Character::queue_play(QueuedPlay play)
|
||||||
{
|
{
|
||||||
|
if (isStageUp) return;
|
||||||
queuedPlay = play;
|
queuedPlay = play;
|
||||||
queuedPlay.animation = animation_name_convert(queuedPlay.animation);
|
queuedPlay.animation = animation_name_convert(queuedPlay.animation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Character::queue_idle_animation()
|
void Character::queue_idle_animation()
|
||||||
{
|
{
|
||||||
|
if (isStageUp) return;
|
||||||
if (data.animations.idle.empty()) return;
|
if (data.animations.idle.empty()) return;
|
||||||
queue_play(
|
queue_play(
|
||||||
{is_over_capacity() && !data.animations.idleFull.empty() ? data.animations.idleFull : data.animations.idle});
|
{is_over_capacity() && !data.animations.idleFull.empty() ? data.animations.idleFull : data.animations.idle});
|
||||||
@@ -348,6 +350,7 @@ namespace game::entity
|
|||||||
|
|
||||||
void Character::queue_interact_area_animation(resource::xml::Character::InteractArea& interactArea)
|
void Character::queue_interact_area_animation(resource::xml::Character::InteractArea& interactArea)
|
||||||
{
|
{
|
||||||
|
if (isStageUp) return;
|
||||||
if (interactArea.animation.empty()) return;
|
if (interactArea.animation.empty()) return;
|
||||||
queue_play({is_over_capacity() && !interactArea.animationFull.empty() ? interactArea.animationFull
|
queue_play({is_over_capacity() && !interactArea.animationFull.empty() ? interactArea.animationFull
|
||||||
: interactArea.animation});
|
: interactArea.animation});
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ namespace game::entity
|
|||||||
std::vector<int> animationBlinkDurations{};
|
std::vector<int> animationBlinkDurations{};
|
||||||
|
|
||||||
bool isStageUp{};
|
bool isStageUp{};
|
||||||
|
bool isStageUpDuring{};
|
||||||
bool isJustStageUp{};
|
bool isJustStageUp{};
|
||||||
bool isJustStageFinal{};
|
bool isJustStageFinal{};
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../util/interact_type.hpp"
|
|
||||||
#include "actor.hpp"
|
#include "actor.hpp"
|
||||||
|
|
||||||
namespace game::entity
|
namespace game::entity
|
||||||
@@ -16,7 +15,7 @@ namespace game::entity
|
|||||||
};
|
};
|
||||||
|
|
||||||
State state{DEFAULT};
|
State state{DEFAULT};
|
||||||
InteractType mode{InteractType::RUB};
|
int interactTypeID{-1};
|
||||||
|
|
||||||
Cursor() = default;
|
Cursor() = default;
|
||||||
Cursor(resource::xml::Anm2&);
|
Cursor(resource::xml::Anm2&);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "log.hpp"
|
#include "log.hpp"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <format>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "util/imgui.hpp"
|
#include "../util/imgui.hpp"
|
||||||
#include "util/math.hpp"
|
#include "../util/math.hpp"
|
||||||
|
|
||||||
using namespace glm;
|
using namespace glm;
|
||||||
using namespace game::resource;
|
using namespace game::resource;
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
#include <glad/glad.h>
|
#include <glad/glad.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "resource/shader.hpp"
|
#include "../resource/shader.hpp"
|
||||||
#include <glm/ext/matrix_clip_space.hpp>
|
#include <glm/ext/matrix_clip_space.hpp>
|
||||||
#include <glm/ext/matrix_transform.hpp>
|
#include <glm/ext/matrix_transform.hpp>
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
@@ -3,7 +3,9 @@
|
|||||||
#include <SDL3/SDL_properties.h>
|
#include <SDL3/SDL_properties.h>
|
||||||
|
|
||||||
#include "../log.hpp"
|
#include "../log.hpp"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <format>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
using namespace game::util;
|
using namespace game::util;
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include "../log.hpp"
|
#include "../log.hpp"
|
||||||
|
|
||||||
|
#include <format>
|
||||||
|
|
||||||
using namespace game::util;
|
using namespace game::util;
|
||||||
|
|
||||||
static ImFont* default_font_fallback_get()
|
static ImFont* default_font_fallback_get()
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include "../log.hpp"
|
#include "../log.hpp"
|
||||||
|
|
||||||
|
#include <format>
|
||||||
|
|
||||||
namespace game::resource
|
namespace game::resource
|
||||||
{
|
{
|
||||||
Shader::Shader(const char* vertex, const char* fragment)
|
Shader::Shader(const char* vertex, const char* fragment)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <SDL3/SDL_surface.h>
|
#include <SDL3/SDL_surface.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <format>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
#include "../log.hpp"
|
#include "../log.hpp"
|
||||||
|
|||||||
@@ -4,8 +4,9 @@
|
|||||||
|
|
||||||
namespace game::resource::xml
|
namespace game::resource::xml
|
||||||
{
|
{
|
||||||
const std::string& AnimationEntryCollection::get()
|
std::string* AnimationEntryCollection::get()
|
||||||
{
|
{
|
||||||
return at(util::vector::random_index_weighted(*this, [](const auto& entry) { return entry.weight; })).animation;
|
if (empty()) return nullptr;
|
||||||
|
return &at(util::vector::random_index_weighted(*this, [](const auto& entry) { return entry.weight; })).animation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace game::resource::xml
|
|||||||
class AnimationEntryCollection : public std::vector<AnimationEntry>
|
class AnimationEntryCollection : public std::vector<AnimationEntry>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const std::string& get();
|
std::string* get();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include "../../log.hpp"
|
#include "../../log.hpp"
|
||||||
|
|
||||||
|
#include <format>
|
||||||
#include <ranges>
|
#include <ranges>
|
||||||
|
|
||||||
using namespace tinyxml2;
|
using namespace tinyxml2;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "area.hpp"
|
#include "area.hpp"
|
||||||
|
|
||||||
#include "../../log.hpp"
|
#include "../../log.hpp"
|
||||||
|
#include <format>
|
||||||
|
|
||||||
#include "util.hpp"
|
#include "util.hpp"
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
#include "../../util/preferences.hpp"
|
#include "../../util/preferences.hpp"
|
||||||
#include "util.hpp"
|
#include "util.hpp"
|
||||||
|
|
||||||
|
#include <format>
|
||||||
|
|
||||||
using namespace tinyxml2;
|
using namespace tinyxml2;
|
||||||
using namespace game::util;
|
using namespace game::util;
|
||||||
|
|
||||||
@@ -39,6 +41,8 @@ namespace game::resource::xml
|
|||||||
query_anm2(root, "Anm2", archive, textureRootPath, anm2);
|
query_anm2(root, "Anm2", archive, textureRootPath, anm2);
|
||||||
query_string_attribute(root, "Name", &name);
|
query_string_attribute(root, "Name", &name);
|
||||||
|
|
||||||
|
query_vec3(root, "ColorR", "ColorG", "ColorB", color);
|
||||||
|
|
||||||
root->QueryFloatAttribute("Weight", &weight);
|
root->QueryFloatAttribute("Weight", &weight);
|
||||||
|
|
||||||
root->QueryFloatAttribute("Capacity", &capacity);
|
root->QueryFloatAttribute("Capacity", &capacity);
|
||||||
@@ -157,6 +161,15 @@ namespace game::resource::xml
|
|||||||
|
|
||||||
if (auto element = root->FirstChildElement("InteractAreas"))
|
if (auto element = root->FirstChildElement("InteractAreas"))
|
||||||
{
|
{
|
||||||
|
auto interact_type_id_get = [&](const std::string& typeName)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < (int)interactTypeNames.size(); i++)
|
||||||
|
if (interactTypeNames[i] == typeName) return i;
|
||||||
|
|
||||||
|
interactTypeNames.emplace_back(typeName);
|
||||||
|
return (int)interactTypeNames.size() - 1;
|
||||||
|
};
|
||||||
|
|
||||||
for (auto child = element->FirstChildElement("InteractArea"); child;
|
for (auto child = element->FirstChildElement("InteractArea"); child;
|
||||||
child = child->NextSiblingElement("InteractArea"))
|
child = child->NextSiblingElement("InteractArea"))
|
||||||
{
|
{
|
||||||
@@ -171,6 +184,7 @@ namespace game::resource::xml
|
|||||||
query_string_attribute(child, "AnimationCursorActive", &interactArea.animationCursorActive);
|
query_string_attribute(child, "AnimationCursorActive", &interactArea.animationCursorActive);
|
||||||
query_sound_entry_collection(child, "Sound", archive, soundRootPath, interactArea.sound, "Path");
|
query_sound_entry_collection(child, "Sound", archive, soundRootPath, interactArea.sound, "Path");
|
||||||
dialogue.query_pool_id(child, "DialoguePoolID", interactArea.pool.id);
|
dialogue.query_pool_id(child, "DialoguePoolID", interactArea.pool.id);
|
||||||
|
query_bool_attribute(child, "IsHold", &interactArea.isHold);
|
||||||
child->QueryFloatAttribute("DigestionBonusRub", &interactArea.digestionBonusRub);
|
child->QueryFloatAttribute("DigestionBonusRub", &interactArea.digestionBonusRub);
|
||||||
child->QueryFloatAttribute("DigestionBonusClick", &interactArea.digestionBonusClick);
|
child->QueryFloatAttribute("DigestionBonusClick", &interactArea.digestionBonusClick);
|
||||||
child->QueryFloatAttribute("Time", &interactArea.time);
|
child->QueryFloatAttribute("Time", &interactArea.time);
|
||||||
@@ -179,9 +193,7 @@ namespace game::resource::xml
|
|||||||
|
|
||||||
std::string typeString{};
|
std::string typeString{};
|
||||||
query_string_attribute(child, "Type", &typeString);
|
query_string_attribute(child, "Type", &typeString);
|
||||||
|
if (!typeString.empty()) interactArea.typeID = interact_type_id_get(typeString);
|
||||||
for (int i = 0; i < (int)std::size(INTERACT_TYPE_STRINGS); i++)
|
|
||||||
if (typeString == INTERACT_TYPE_STRINGS[i]) interactArea.type = (InteractType)i;
|
|
||||||
|
|
||||||
interactAreas.emplace_back(std::move(interactArea));
|
interactAreas.emplace_back(std::move(interactArea));
|
||||||
}
|
}
|
||||||
@@ -208,10 +220,10 @@ namespace game::resource::xml
|
|||||||
else
|
else
|
||||||
logger.warning(std::format("No character cursor.xml file found: {}", path.string()));
|
logger.warning(std::format("No character cursor.xml file found: {}", path.string()));
|
||||||
|
|
||||||
if (auto playSchemaPath = physfs::Path(archive + "/" + "play.xml"); playSchemaPath.is_valid())
|
if (auto skillCheckSchemaPath = physfs::Path(archive + "/" + "skill_check.xml"); skillCheckSchemaPath.is_valid())
|
||||||
playSchema = Play(playSchemaPath, dialogue);
|
skillCheckSchema = SkillCheck(skillCheckSchemaPath, dialogue);
|
||||||
else
|
else
|
||||||
logger.warning(std::format("No character play.xml file found: {}", path.string()));
|
logger.warning(std::format("No character skill_check.xml file found: {}", path.string()));
|
||||||
|
|
||||||
logger.info(std::format("Initialized character: {}", name));
|
logger.info(std::format("Initialized character: {}", name));
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "../../util/interact_type.hpp"
|
|
||||||
#include "../audio.hpp"
|
#include "../audio.hpp"
|
||||||
#include "animation_entry.hpp"
|
#include "animation_entry.hpp"
|
||||||
#include "anm2.hpp"
|
#include "anm2.hpp"
|
||||||
@@ -12,7 +11,7 @@
|
|||||||
#include "dialogue.hpp"
|
#include "dialogue.hpp"
|
||||||
#include "item.hpp"
|
#include "item.hpp"
|
||||||
#include "menu.hpp"
|
#include "menu.hpp"
|
||||||
#include "play.hpp"
|
#include "skill_check.hpp"
|
||||||
#include "save.hpp"
|
#include "save.hpp"
|
||||||
|
|
||||||
namespace game::resource::xml
|
namespace game::resource::xml
|
||||||
@@ -51,7 +50,8 @@ namespace game::resource::xml
|
|||||||
|
|
||||||
int nullID{-1};
|
int nullID{-1};
|
||||||
int layerID{-1};
|
int layerID{-1};
|
||||||
InteractType type{(InteractType)-1};
|
int typeID{-1};
|
||||||
|
bool isHold{};
|
||||||
Dialogue::PoolReference pool{-1};
|
Dialogue::PoolReference pool{-1};
|
||||||
|
|
||||||
float digestionBonusRub{};
|
float digestionBonusRub{};
|
||||||
@@ -97,7 +97,7 @@ namespace game::resource::xml
|
|||||||
Item itemSchema{};
|
Item itemSchema{};
|
||||||
Menu menuSchema{};
|
Menu menuSchema{};
|
||||||
Cursor cursorSchema{};
|
Cursor cursorSchema{};
|
||||||
Play playSchema{};
|
SkillCheck skillCheckSchema{};
|
||||||
|
|
||||||
Save save{};
|
Save save{};
|
||||||
|
|
||||||
@@ -107,9 +107,12 @@ namespace game::resource::xml
|
|||||||
|
|
||||||
Sounds sounds{};
|
Sounds sounds{};
|
||||||
|
|
||||||
|
glm::vec3 color{0.120f, 0.515f, 0.115f};
|
||||||
|
|
||||||
std::vector<Stage> stages{};
|
std::vector<Stage> stages{};
|
||||||
std::vector<ExpandArea> expandAreas{};
|
std::vector<ExpandArea> expandAreas{};
|
||||||
std::vector<EatArea> eatAreas{};
|
std::vector<EatArea> eatAreas{};
|
||||||
|
std::vector<std::string> interactTypeNames{};
|
||||||
std::vector<InteractArea> interactAreas{};
|
std::vector<InteractArea> interactAreas{};
|
||||||
|
|
||||||
AlternateSpritesheet alternateSpritesheet{};
|
AlternateSpritesheet alternateSpritesheet{};
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
#include "../../util/preferences.hpp"
|
#include "../../util/preferences.hpp"
|
||||||
#include "util.hpp"
|
#include "util.hpp"
|
||||||
|
|
||||||
|
#include <format>
|
||||||
|
|
||||||
using namespace tinyxml2;
|
using namespace tinyxml2;
|
||||||
using namespace game::util;
|
using namespace game::util;
|
||||||
|
|
||||||
@@ -40,6 +42,7 @@ namespace game::resource::xml
|
|||||||
query_string_attribute(root, "Name", &name);
|
query_string_attribute(root, "Name", &name);
|
||||||
query_string_attribute(root, "Description", &description);
|
query_string_attribute(root, "Description", &description);
|
||||||
query_string_attribute(root, "Author", &author);
|
query_string_attribute(root, "Author", &author);
|
||||||
|
query_vec3(root, "ColorR", "ColorG", "ColorB", color);
|
||||||
root->QueryFloatAttribute("Weight", &weight);
|
root->QueryFloatAttribute("Weight", &weight);
|
||||||
|
|
||||||
if (auto element = root->FirstChildElement("Stages"))
|
if (auto element = root->FirstChildElement("Stages"))
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
#include <glm/glm.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -22,6 +23,7 @@ namespace game::resource::xml
|
|||||||
Texture portrait{};
|
Texture portrait{};
|
||||||
Texture render{};
|
Texture render{};
|
||||||
Save save{};
|
Save save{};
|
||||||
|
glm::vec3 color{0.120f, 0.515f, 0.115f};
|
||||||
|
|
||||||
int stages{1};
|
int stages{1};
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include "../../log.hpp"
|
#include "../../log.hpp"
|
||||||
|
|
||||||
|
#include <format>
|
||||||
|
|
||||||
using namespace tinyxml2;
|
using namespace tinyxml2;
|
||||||
using namespace game::util;
|
using namespace game::util;
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
#include "../../log.hpp"
|
#include "../../log.hpp"
|
||||||
#include "../../util/math.hpp"
|
#include "../../util/math.hpp"
|
||||||
|
|
||||||
|
#include <format>
|
||||||
|
|
||||||
using namespace tinyxml2;
|
using namespace tinyxml2;
|
||||||
using namespace game::util;
|
using namespace game::util;
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
#include "../../log.hpp"
|
#include "../../log.hpp"
|
||||||
|
|
||||||
|
#include <format>
|
||||||
|
|
||||||
#include "util.hpp"
|
#include "util.hpp"
|
||||||
|
|
||||||
using namespace tinyxml2;
|
using namespace tinyxml2;
|
||||||
@@ -85,6 +87,22 @@ namespace game::resource::xml
|
|||||||
query_sound_entry_collection(element, "Dispose", archive, soundRootPath, sounds.dispose);
|
query_sound_entry_collection(element, "Dispose", archive, soundRootPath, sounds.dispose);
|
||||||
query_sound_entry_collection(element, "Return", archive, soundRootPath, sounds.return_);
|
query_sound_entry_collection(element, "Return", archive, soundRootPath, sounds.return_);
|
||||||
query_sound_entry_collection(element, "Summon", archive, soundRootPath, sounds.summon);
|
query_sound_entry_collection(element, "Summon", archive, soundRootPath, sounds.summon);
|
||||||
|
query_sound_entry_collection(element, "Upgrade", archive, soundRootPath, sounds.upgrade);
|
||||||
|
query_sound_entry_collection(element, "UpgradeFail", archive, soundRootPath, sounds.upgradeFail);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (auto element = root->FirstChildElement("Items"))
|
||||||
|
{
|
||||||
|
int id{};
|
||||||
|
|
||||||
|
for (auto child = element->FirstChildElement("Item"); child; child = child->NextSiblingElement("Item"))
|
||||||
|
{
|
||||||
|
std::string name{};
|
||||||
|
query_string_attribute(child, "Name", &name);
|
||||||
|
stringToIDMap[name] = id;
|
||||||
|
idToStringMap[id] = name;
|
||||||
|
id++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto element = root->FirstChildElement("Items"))
|
if (auto element = root->FirstChildElement("Items"))
|
||||||
@@ -106,8 +124,25 @@ namespace game::resource::xml
|
|||||||
query_float_optional_attribute(child, "DigestionBonus", item.digestionBonus);
|
query_float_optional_attribute(child, "DigestionBonus", item.digestionBonus);
|
||||||
query_float_optional_attribute(child, "EatSpeedBonus", item.eatSpeedBonus);
|
query_float_optional_attribute(child, "EatSpeedBonus", item.eatSpeedBonus);
|
||||||
query_float_optional_attribute(child, "Gravity", item.gravity);
|
query_float_optional_attribute(child, "Gravity", item.gravity);
|
||||||
|
|
||||||
query_int_optional_attribute(child, "ChewCount", item.chewCount);
|
query_int_optional_attribute(child, "ChewCount", item.chewCount);
|
||||||
query_bool_attribute(child, "IsPlayReward", &item.isPlayReward);
|
|
||||||
|
if (child->FindAttribute("UpgradeID"))
|
||||||
|
{
|
||||||
|
std::string upgradeIDString{};
|
||||||
|
query_string_attribute(child, "UpgradeID", &upgradeIDString);
|
||||||
|
|
||||||
|
if (!upgradeIDString.empty() && stringToIDMap.contains(upgradeIDString))
|
||||||
|
item.upgradeID = stringToIDMap[upgradeIDString];
|
||||||
|
else if (upgradeIDString.empty())
|
||||||
|
logger.warning(std::format("Empty UpgradeID ({})", item.name));
|
||||||
|
else
|
||||||
|
logger.warning(std::format("Could not find item ID for UpgradeID: {} ({})", upgradeIDString, item.name));
|
||||||
|
|
||||||
|
query_int_optional_attribute(child, "UpgradeCount", item.upgradeCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
query_bool_attribute(child, "IsSkillCheckReward", &item.isSkillCheckReward);
|
||||||
query_bool_attribute(child, "IsToggleSpritesheet", &item.isToggleSpritesheet);
|
query_bool_attribute(child, "IsToggleSpritesheet", &item.isToggleSpritesheet);
|
||||||
|
|
||||||
std::string categoryString{};
|
std::string categoryString{};
|
||||||
@@ -138,7 +173,7 @@ namespace game::resource::xml
|
|||||||
{
|
{
|
||||||
auto& item = items[i];
|
auto& item = items[i];
|
||||||
pools[item.rarityID].emplace_back(i);
|
pools[item.rarityID].emplace_back(i);
|
||||||
if (item.isPlayReward) rewardItemPool.emplace_back(i);
|
if (item.isSkillCheckReward) skillCheckRewardItemPool.emplace_back(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < (int)rarities.size(); i++)
|
for (int i = 0; i < (int)rarities.size(); i++)
|
||||||
|
|||||||
@@ -42,13 +42,15 @@ namespace game::resource::xml
|
|||||||
std::string description{UNDEFINED};
|
std::string description{UNDEFINED};
|
||||||
int categoryID{};
|
int categoryID{};
|
||||||
int rarityID{};
|
int rarityID{};
|
||||||
|
std::optional<int> upgradeCount{};
|
||||||
|
std::optional<int> upgradeID{};
|
||||||
std::optional<int> flavorID;
|
std::optional<int> flavorID;
|
||||||
std::optional<float> calories{};
|
std::optional<float> calories{};
|
||||||
std::optional<float> eatSpeedBonus{};
|
std::optional<float> eatSpeedBonus{};
|
||||||
std::optional<float> digestionBonus{};
|
std::optional<float> digestionBonus{};
|
||||||
std::optional<float> gravity{};
|
std::optional<float> gravity{};
|
||||||
std::optional<int> chewCount{};
|
std::optional<int> chewCount{};
|
||||||
bool isPlayReward{};
|
bool isSkillCheckReward{};
|
||||||
bool isToggleSpritesheet{};
|
bool isToggleSpritesheet{};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -63,11 +65,15 @@ namespace game::resource::xml
|
|||||||
SoundEntryCollection return_{};
|
SoundEntryCollection return_{};
|
||||||
SoundEntryCollection dispose{};
|
SoundEntryCollection dispose{};
|
||||||
SoundEntryCollection summon{};
|
SoundEntryCollection summon{};
|
||||||
|
SoundEntryCollection upgrade{};
|
||||||
|
SoundEntryCollection upgradeFail{};
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unordered_map<std::string, int> categoryMap{};
|
std::unordered_map<std::string, int> categoryMap{};
|
||||||
std::unordered_map<std::string, int> rarityMap{};
|
std::unordered_map<std::string, int> rarityMap{};
|
||||||
std::unordered_map<std::string, int> flavorMap{};
|
std::unordered_map<std::string, int> flavorMap{};
|
||||||
|
std::unordered_map<std::string, int> stringToIDMap{};
|
||||||
|
std::unordered_map<int, std::string> idToStringMap{};
|
||||||
|
|
||||||
using Pool = std::vector<int>;
|
using Pool = std::vector<int>;
|
||||||
|
|
||||||
@@ -79,7 +85,7 @@ namespace game::resource::xml
|
|||||||
|
|
||||||
std::vector<int> rarityIDsSortedByChance{};
|
std::vector<int> rarityIDsSortedByChance{};
|
||||||
std::unordered_map<int, Pool> pools{};
|
std::unordered_map<int, Pool> pools{};
|
||||||
Pool rewardItemPool{};
|
Pool skillCheckRewardItemPool{};
|
||||||
|
|
||||||
Animations animations{};
|
Animations animations{};
|
||||||
Sounds sounds{};
|
Sounds sounds{};
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include "../../log.hpp"
|
#include "../../log.hpp"
|
||||||
|
|
||||||
|
#include <format>
|
||||||
|
|
||||||
#include "util.hpp"
|
#include "util.hpp"
|
||||||
|
|
||||||
using namespace tinyxml2;
|
using namespace tinyxml2;
|
||||||
@@ -34,6 +36,7 @@ namespace game::resource::xml
|
|||||||
query_sound_entry_collection(element, "Close", archive, soundRootPath, sounds.close);
|
query_sound_entry_collection(element, "Close", archive, soundRootPath, sounds.close);
|
||||||
query_sound_entry_collection(element, "Hover", archive, soundRootPath, sounds.hover);
|
query_sound_entry_collection(element, "Hover", archive, soundRootPath, sounds.hover);
|
||||||
query_sound_entry_collection(element, "Select", archive, soundRootPath, sounds.select);
|
query_sound_entry_collection(element, "Select", archive, soundRootPath, sounds.select);
|
||||||
|
query_sound_entry_collection(element, "CheatsActivated", archive, soundRootPath, sounds.cheatsActivated);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ namespace game::resource::xml
|
|||||||
SoundEntryCollection close{};
|
SoundEntryCollection close{};
|
||||||
SoundEntryCollection hover{};
|
SoundEntryCollection hover{};
|
||||||
SoundEntryCollection select{};
|
SoundEntryCollection select{};
|
||||||
|
SoundEntryCollection cheatsActivated{};
|
||||||
};
|
};
|
||||||
|
|
||||||
Sounds sounds{};
|
Sounds sounds{};
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
#include "../../log.hpp"
|
#include "../../log.hpp"
|
||||||
|
|
||||||
|
#include <format>
|
||||||
|
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
#include "../../util/web_filesystem.hpp"
|
#include "../../util/web_filesystem.hpp"
|
||||||
#endif
|
#endif
|
||||||
@@ -20,15 +22,13 @@ namespace game::resource::xml
|
|||||||
XMLDocument document;
|
XMLDocument document;
|
||||||
auto pathString = path.string();
|
auto pathString = path.string();
|
||||||
|
|
||||||
// Fail silently if there's no save.
|
|
||||||
auto result = document.LoadFile(pathString.c_str());
|
auto result = document.LoadFile(pathString.c_str());
|
||||||
|
|
||||||
if (result == XML_ERROR_FILE_NOT_FOUND || result == XML_ERROR_FILE_COULD_NOT_BE_OPENED) return;
|
if (result == XML_ERROR_FILE_NOT_FOUND || result == XML_ERROR_FILE_COULD_NOT_BE_OPENED) return;
|
||||||
|
|
||||||
if (result != XML_SUCCESS)
|
if (result != XML_SUCCESS)
|
||||||
{
|
{
|
||||||
logger.error(
|
logger.error(std::format("Could not initialize character save file: {} ({})", pathString, document.ErrorStr()));
|
||||||
std::format("Could not initialize character save file: {} ({})", pathString, document.ErrorStr()));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +52,9 @@ namespace game::resource::xml
|
|||||||
element->QueryIntAttribute("TotalFoodItemsEaten", &totalFoodItemsEaten);
|
element->QueryIntAttribute("TotalFoodItemsEaten", &totalFoodItemsEaten);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto element = root->FirstChildElement("Play"))
|
auto element = root->FirstChildElement("SkillCheck");
|
||||||
|
if (!element) element = root->FirstChildElement("Play");
|
||||||
|
if (element)
|
||||||
{
|
{
|
||||||
element->QueryIntAttribute("TotalPlays", &totalPlays);
|
element->QueryIntAttribute("TotalPlays", &totalPlays);
|
||||||
element->QueryIntAttribute("HighScore", &highScore);
|
element->QueryIntAttribute("HighScore", &highScore);
|
||||||
@@ -128,13 +130,13 @@ namespace game::resource::xml
|
|||||||
characterElement->SetAttribute("TotalCaloriesConsumed", totalCaloriesConsumed);
|
characterElement->SetAttribute("TotalCaloriesConsumed", totalCaloriesConsumed);
|
||||||
characterElement->SetAttribute("TotalFoodItemsEaten", totalFoodItemsEaten);
|
characterElement->SetAttribute("TotalFoodItemsEaten", totalFoodItemsEaten);
|
||||||
|
|
||||||
auto playElement = element->InsertNewChildElement("Play");
|
auto skillCheckElement = element->InsertNewChildElement("SkillCheck");
|
||||||
|
|
||||||
playElement->SetAttribute("TotalPlays", totalPlays);
|
skillCheckElement->SetAttribute("TotalPlays", totalPlays);
|
||||||
playElement->SetAttribute("HighScore", highScore);
|
skillCheckElement->SetAttribute("HighScore", highScore);
|
||||||
playElement->SetAttribute("BestCombo", bestCombo);
|
skillCheckElement->SetAttribute("BestCombo", bestCombo);
|
||||||
|
|
||||||
auto gradesElement = playElement->InsertNewChildElement("Grades");
|
auto gradesElement = skillCheckElement->InsertNewChildElement("Grades");
|
||||||
|
|
||||||
for (auto& [i, count] : gradeCounts)
|
for (auto& [i, count] : gradeCounts)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
#include "../../log.hpp"
|
#include "../../log.hpp"
|
||||||
|
|
||||||
|
#include <format>
|
||||||
|
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
#include "../../util/web_filesystem.hpp"
|
#include "../../util/web_filesystem.hpp"
|
||||||
#endif
|
#endif
|
||||||
@@ -21,8 +23,7 @@ namespace game::resource::xml
|
|||||||
|
|
||||||
if (document.LoadFile(pathString.c_str()) != XML_SUCCESS)
|
if (document.LoadFile(pathString.c_str()) != XML_SUCCESS)
|
||||||
{
|
{
|
||||||
logger.error(
|
logger.error(std::format("Could not initialize character save file: {} ({})", pathString, document.ErrorStr()));
|
||||||
std::format("Could not initialize character save file: {} ({})", pathString, document.ErrorStr()));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,13 +33,10 @@ namespace game::resource::xml
|
|||||||
query_string_attribute(root, "MeasurementSystem", &measurementSystemString);
|
query_string_attribute(root, "MeasurementSystem", &measurementSystemString);
|
||||||
measurementSystem = measurementSystemString == "Imperial" ? measurement::IMPERIAL : measurement::METRIC;
|
measurementSystem = measurementSystemString == "Imperial" ? measurement::IMPERIAL : measurement::METRIC;
|
||||||
root->QueryIntAttribute("Volume", &volume);
|
root->QueryIntAttribute("Volume", &volume);
|
||||||
root->QueryFloatAttribute("ColorR", &color.r);
|
query_vec3(root, "ColorR", "ColorG", "ColorB", color);
|
||||||
root->QueryFloatAttribute("ColorG", &color.g);
|
query_vec2(root, "WindowX", "WindowY", windowPosition);
|
||||||
root->QueryFloatAttribute("ColorB", &color.b);
|
query_ivec2(root, "WindowW", "WindowH", windowSize);
|
||||||
root->QueryFloatAttribute("WindowX", &windowPosition.x);
|
query_bool_attribute(root, "IsUseCharacterColor", &isUseCharacterColor);
|
||||||
root->QueryFloatAttribute("WindowY", &windowPosition.y);
|
|
||||||
root->QueryIntAttribute("WindowW", &windowSize.x);
|
|
||||||
root->QueryIntAttribute("WindowH", &windowSize.y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(std::format("Initialized settings: {}", pathString));
|
logger.info(std::format("Initialized settings: {}", pathString));
|
||||||
@@ -57,13 +55,10 @@ namespace game::resource::xml
|
|||||||
|
|
||||||
element->SetAttribute("MeasurementSystem", measurementSystem == measurement::IMPERIAL ? "Imperial" : "Metric");
|
element->SetAttribute("MeasurementSystem", measurementSystem == measurement::IMPERIAL ? "Imperial" : "Metric");
|
||||||
element->SetAttribute("Volume", volume);
|
element->SetAttribute("Volume", volume);
|
||||||
element->SetAttribute("ColorR", color.r);
|
set_vec3_attribute(element, "ColorR", "ColorG", "ColorB", color);
|
||||||
element->SetAttribute("ColorG", color.g);
|
set_vec2_attribute(element, "WindowX", "WindowY", windowPosition);
|
||||||
element->SetAttribute("ColorB", color.b);
|
set_ivec2_attribute(element, "WindowW", "WindowH", windowSize);
|
||||||
element->SetAttribute("WindowX", windowPosition.x);
|
set_bool_attribute(element, "IsUseCharacterColor", isUseCharacterColor);
|
||||||
element->SetAttribute("WindowY", windowPosition.y);
|
|
||||||
element->SetAttribute("WindowW", windowSize.x);
|
|
||||||
element->SetAttribute("WindowH", windowSize.y);
|
|
||||||
|
|
||||||
document.InsertFirstChild(element);
|
document.InsertFirstChild(element);
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ namespace game::resource::xml
|
|||||||
|
|
||||||
util::measurement::System measurementSystem{util::measurement::METRIC};
|
util::measurement::System measurementSystem{util::measurement::METRIC};
|
||||||
int volume{50};
|
int volume{50};
|
||||||
|
bool isUseCharacterColor{true};
|
||||||
|
|
||||||
glm::vec3 color{0.120f, 0.515f, 0.115f};
|
glm::vec3 color{0.120f, 0.515f, 0.115f};
|
||||||
glm::ivec2 windowSize{1600, 900};
|
glm::ivec2 windowSize{1600, 900};
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
#include "play.hpp"
|
#include "skill_check.hpp"
|
||||||
|
|
||||||
#include "../../log.hpp"
|
#include "../../log.hpp"
|
||||||
#include "util.hpp"
|
#include "util.hpp"
|
||||||
|
|
||||||
|
#include <format>
|
||||||
|
|
||||||
using namespace tinyxml2;
|
using namespace tinyxml2;
|
||||||
using namespace game::util;
|
using namespace game::util;
|
||||||
|
|
||||||
namespace game::resource::xml
|
namespace game::resource::xml
|
||||||
{
|
{
|
||||||
Play::Play(const physfs::Path& path, Dialogue& dialogue)
|
SkillCheck::SkillCheck(const physfs::Path& path, Dialogue& dialogue)
|
||||||
{
|
{
|
||||||
XMLDocument document;
|
XMLDocument document;
|
||||||
|
|
||||||
@@ -60,8 +62,8 @@ namespace game::resource::xml
|
|||||||
}
|
}
|
||||||
|
|
||||||
isValid = true;
|
isValid = true;
|
||||||
logger.info(std::format("Initialized play schema: {}", path.c_str()));
|
logger.info(std::format("Initialized skill check schema: {}", path.c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Play::is_valid() const { return isValid; };
|
bool SkillCheck::is_valid() const { return isValid; };
|
||||||
}
|
}
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
namespace game::resource::xml
|
namespace game::resource::xml
|
||||||
{
|
{
|
||||||
class Play
|
class SkillCheck
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
struct Grade
|
struct Grade
|
||||||
@@ -48,8 +48,8 @@ namespace game::resource::xml
|
|||||||
|
|
||||||
bool isValid{};
|
bool isValid{};
|
||||||
|
|
||||||
Play() = default;
|
SkillCheck() = default;
|
||||||
Play(const util::physfs::Path&, Dialogue&);
|
SkillCheck(const util::physfs::Path&, Dialogue&);
|
||||||
|
|
||||||
bool is_valid() const;
|
bool is_valid() const;
|
||||||
};
|
};
|
||||||
@@ -4,13 +4,15 @@
|
|||||||
|
|
||||||
namespace game::resource::xml
|
namespace game::resource::xml
|
||||||
{
|
{
|
||||||
Audio& SoundEntryCollection::get()
|
Audio* SoundEntryCollection::get()
|
||||||
{
|
{
|
||||||
return at(util::vector::random_index_weighted(*this, [](const auto& entry) { return entry.weight; })).sound;
|
if (empty()) return nullptr;
|
||||||
|
return &at(util::vector::random_index_weighted(*this, [](const auto& entry) { return entry.weight; })).sound;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundEntryCollection::play()
|
void SoundEntryCollection::play()
|
||||||
{
|
{
|
||||||
at(util::vector::random_index_weighted(*this, [](const auto& entry) { return entry.weight; })).play();
|
if (empty()) return;
|
||||||
|
if (auto audio = get()) audio->play();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace game::resource::xml
|
|||||||
class SoundEntryCollection : public std::vector<SoundEntry>
|
class SoundEntryCollection : public std::vector<SoundEntry>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Audio& get();
|
Audio* get();
|
||||||
void play();
|
void play();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ using namespace game::util;
|
|||||||
|
|
||||||
namespace game::resource::xml
|
namespace game::resource::xml
|
||||||
{
|
{
|
||||||
|
XMLError query_result_merge(XMLError result, XMLError next) { return result == XML_SUCCESS ? next : result; }
|
||||||
|
|
||||||
XMLError query_string_attribute(XMLElement* element, const char* attribute, std::string* value)
|
XMLError query_string_attribute(XMLElement* element, const char* attribute, std::string* value)
|
||||||
{
|
{
|
||||||
const char* temp = nullptr;
|
const char* temp = nullptr;
|
||||||
@@ -45,6 +47,60 @@ namespace game::resource::xml
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XMLError query_ivec2(XMLElement* element, const char* attributeX, const char* attributeY, glm::ivec2& value)
|
||||||
|
{
|
||||||
|
auto result = element->QueryIntAttribute(attributeX, &value.x);
|
||||||
|
result = query_result_merge(result, element->QueryIntAttribute(attributeY, &value.y));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
XMLError query_vec2(XMLElement* element, const char* attributeX, const char* attributeY, glm::vec2& value)
|
||||||
|
{
|
||||||
|
auto result = element->QueryFloatAttribute(attributeX, &value.x);
|
||||||
|
result = query_result_merge(result, element->QueryFloatAttribute(attributeY, &value.y));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
XMLError query_vec3(XMLElement* element, const char* attributeX, const char* attributeY, const char* attributeZ,
|
||||||
|
glm::vec3& value)
|
||||||
|
{
|
||||||
|
auto result = element->QueryFloatAttribute(attributeX, &value.x);
|
||||||
|
result = query_result_merge(result, element->QueryFloatAttribute(attributeY, &value.y));
|
||||||
|
result = query_result_merge(result, element->QueryFloatAttribute(attributeZ, &value.z));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
XMLError set_bool_attribute(XMLElement* element, const char* attribute, bool value)
|
||||||
|
{
|
||||||
|
element->SetAttribute(attribute, value ? "true" : "false");
|
||||||
|
return XML_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
XMLError set_ivec2_attribute(XMLElement* element, const char* attributeX, const char* attributeY,
|
||||||
|
const glm::ivec2& value)
|
||||||
|
{
|
||||||
|
element->SetAttribute(attributeX, value.x);
|
||||||
|
element->SetAttribute(attributeY, value.y);
|
||||||
|
return XML_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
XMLError set_vec2_attribute(XMLElement* element, const char* attributeX, const char* attributeY,
|
||||||
|
const glm::vec2& value)
|
||||||
|
{
|
||||||
|
element->SetAttribute(attributeX, value.x);
|
||||||
|
element->SetAttribute(attributeY, value.y);
|
||||||
|
return XML_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
XMLError set_vec3_attribute(XMLElement* element, const char* attributeX, const char* attributeY,
|
||||||
|
const char* attributeZ, const glm::vec3& value)
|
||||||
|
{
|
||||||
|
element->SetAttribute(attributeX, value.x);
|
||||||
|
element->SetAttribute(attributeY, value.y);
|
||||||
|
element->SetAttribute(attributeZ, value.z);
|
||||||
|
return XML_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
XMLError query_float_optional_attribute(XMLElement* element, const char* attribute, std::optional<float>& value)
|
XMLError query_float_optional_attribute(XMLElement* element, const char* attribute, std::optional<float>& value)
|
||||||
{
|
{
|
||||||
value.emplace();
|
value.emplace();
|
||||||
@@ -84,102 +140,139 @@ namespace game::resource::xml
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void query_event_id(XMLElement* element, const char* name, const Anm2& anm2, int& eventID)
|
XMLError query_event_id(XMLElement* element, const char* name, const Anm2& anm2, int& eventID)
|
||||||
{
|
{
|
||||||
std::string string{};
|
std::string string{};
|
||||||
query_string_attribute(element, name, &string);
|
auto result = query_string_attribute(element, name, &string);
|
||||||
|
if (result != XML_SUCCESS) return result;
|
||||||
|
|
||||||
if (anm2.eventMap.contains(string))
|
if (anm2.eventMap.contains(string))
|
||||||
|
{
|
||||||
eventID = anm2.eventMap.at(string);
|
eventID = anm2.eventMap.at(string);
|
||||||
|
return XML_SUCCESS;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.error(std::format("Could not query anm2 event ID: {} ({})", string, anm2.path));
|
logger.error(std::format("Could not query anm2 event ID: {} ({})", string, anm2.path));
|
||||||
eventID = -1;
|
eventID = -1;
|
||||||
|
return XML_ERROR_PARSING_ATTRIBUTE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void query_layer_id(XMLElement* element, const char* name, const Anm2& anm2, int& layerID)
|
XMLError query_layer_id(XMLElement* element, const char* name, const Anm2& anm2, int& layerID)
|
||||||
{
|
{
|
||||||
std::string string{};
|
std::string string{};
|
||||||
query_string_attribute(element, name, &string);
|
auto result = query_string_attribute(element, name, &string);
|
||||||
|
if (result != XML_SUCCESS) return result;
|
||||||
|
|
||||||
if (anm2.layerMap.contains(string))
|
if (anm2.layerMap.contains(string))
|
||||||
|
{
|
||||||
layerID = anm2.layerMap.at(string);
|
layerID = anm2.layerMap.at(string);
|
||||||
|
return XML_SUCCESS;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.error(std::format("Could not query anm2 layer ID: {} ({})", string, anm2.path));
|
logger.error(std::format("Could not query anm2 layer ID: {} ({})", string, anm2.path));
|
||||||
layerID = -1;
|
layerID = -1;
|
||||||
|
return XML_ERROR_PARSING_ATTRIBUTE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void query_null_id(XMLElement* element, const char* name, const Anm2& anm2, int& nullID)
|
XMLError query_null_id(XMLElement* element, const char* name, const Anm2& anm2, int& nullID)
|
||||||
{
|
{
|
||||||
std::string string{};
|
std::string string{};
|
||||||
query_string_attribute(element, name, &string);
|
auto result = query_string_attribute(element, name, &string);
|
||||||
|
if (result != XML_SUCCESS) return result;
|
||||||
|
|
||||||
if (anm2.nullMap.contains(string))
|
if (anm2.nullMap.contains(string))
|
||||||
|
{
|
||||||
nullID = anm2.nullMap.at(string);
|
nullID = anm2.nullMap.at(string);
|
||||||
|
return XML_SUCCESS;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.error(std::format("Could not query anm2 null ID: {} ({})", string, anm2.path));
|
logger.error(std::format("Could not query anm2 null ID: {} ({})", string, anm2.path));
|
||||||
nullID = -1;
|
nullID = -1;
|
||||||
|
return XML_ERROR_PARSING_ATTRIBUTE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void query_anm2(XMLElement* element, const char* name, const std::string& archive, const std::string& rootPath,
|
XMLError query_anm2(XMLElement* element, const char* name, const std::string& archive, const std::string& rootPath,
|
||||||
Anm2& anm2, Anm2::Flags flags)
|
Anm2& anm2, Anm2::Flags flags)
|
||||||
{
|
{
|
||||||
std::string string{};
|
std::string string{};
|
||||||
query_string_attribute(element, name, &string);
|
auto result = query_string_attribute(element, name, &string);
|
||||||
|
if (result != XML_SUCCESS) return result;
|
||||||
|
|
||||||
anm2 = Anm2(physfs::Path(archive + "/" + rootPath + "/" + string), flags);
|
anm2 = Anm2(physfs::Path(archive + "/" + rootPath + "/" + string), flags);
|
||||||
|
return XML_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void query_texture(XMLElement* element, const char* name, const std::string& archive, const std::string& rootPath,
|
XMLError query_texture(XMLElement* element, const char* name, const std::string& archive, const std::string& rootPath,
|
||||||
Texture& texture)
|
Texture& texture)
|
||||||
{
|
{
|
||||||
std::string string{};
|
std::string string{};
|
||||||
query_string_attribute(element, name, &string);
|
auto result = query_string_attribute(element, name, &string);
|
||||||
|
if (result != XML_SUCCESS) return result;
|
||||||
|
|
||||||
texture = Texture(physfs::Path(archive + "/" + rootPath + "/" + string));
|
texture = Texture(physfs::Path(archive + "/" + rootPath + "/" + string));
|
||||||
|
return XML_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void query_sound(XMLElement* element, const char* name, const std::string& archive, const std::string& rootPath,
|
XMLError query_sound(XMLElement* element, const char* name, const std::string& archive, const std::string& rootPath,
|
||||||
Audio& sound)
|
Audio& sound)
|
||||||
{
|
{
|
||||||
std::string string{};
|
std::string string{};
|
||||||
query_string_attribute(element, name, &string);
|
auto result = query_string_attribute(element, name, &string);
|
||||||
|
if (result != XML_SUCCESS) return result;
|
||||||
|
|
||||||
sound = Audio(physfs::Path(archive + "/" + rootPath + "/" + string));
|
sound = Audio(physfs::Path(archive + "/" + rootPath + "/" + string));
|
||||||
|
return XML_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void query_font(XMLElement* element, const char* name, const std::string& archive, const std::string& rootPath,
|
XMLError query_font(XMLElement* element, const char* name, const std::string& archive, const std::string& rootPath,
|
||||||
Font& font)
|
Font& font)
|
||||||
{
|
{
|
||||||
std::string string{};
|
std::string string{};
|
||||||
query_string_attribute(element, name, &string);
|
auto result = query_string_attribute(element, name, &string);
|
||||||
|
if (result != XML_SUCCESS) return result;
|
||||||
|
|
||||||
font = Font(physfs::Path(archive + "/" + rootPath + "/" + string));
|
font = Font(physfs::Path(archive + "/" + rootPath + "/" + string));
|
||||||
|
return XML_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void query_animation_entry(XMLElement* element, AnimationEntry& animationEntry)
|
XMLError query_animation_entry(XMLElement* element, AnimationEntry& animationEntry)
|
||||||
{
|
{
|
||||||
query_string_attribute(element, "Animation", &animationEntry.animation);
|
auto result = query_string_attribute(element, "Animation", &animationEntry.animation);
|
||||||
element->QueryFloatAttribute("Weight", &animationEntry.weight);
|
result = query_result_merge(result, element->QueryFloatAttribute("Weight", &animationEntry.weight));
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void query_animation_entry_collection(XMLElement* element, const char* name,
|
XMLError query_animation_entry_collection(XMLElement* element, const char* name,
|
||||||
AnimationEntryCollection& animationEntryCollection)
|
AnimationEntryCollection& animationEntryCollection)
|
||||||
{
|
{
|
||||||
|
auto result = XML_SUCCESS;
|
||||||
for (auto child = element->FirstChildElement(name); child; child = child->NextSiblingElement(name))
|
for (auto child = element->FirstChildElement(name); child; child = child->NextSiblingElement(name))
|
||||||
query_animation_entry(child, animationEntryCollection.emplace_back());
|
result = query_result_merge(result, query_animation_entry(child, animationEntryCollection.emplace_back()));
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void query_sound_entry(XMLElement* element, const std::string& archive, const std::string& rootPath,
|
XMLError query_sound_entry(XMLElement* element, const std::string& archive, const std::string& rootPath,
|
||||||
SoundEntry& soundEntry, const std::string& attributeName)
|
SoundEntry& soundEntry, const std::string& attributeName)
|
||||||
{
|
{
|
||||||
query_sound(element, attributeName.c_str(), archive, rootPath, soundEntry.sound);
|
auto result = query_sound(element, attributeName.c_str(), archive, rootPath, soundEntry.sound);
|
||||||
element->QueryFloatAttribute("Weight", &soundEntry.weight);
|
result = query_result_merge(result, element->QueryFloatAttribute("Weight", &soundEntry.weight));
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void query_sound_entry_collection(XMLElement* element, const char* name, const std::string& archive,
|
XMLError query_sound_entry_collection(XMLElement* element, const char* name, const std::string& archive,
|
||||||
const std::string& rootPath, SoundEntryCollection& soundEntryCollection,
|
const std::string& rootPath, SoundEntryCollection& soundEntryCollection,
|
||||||
const std::string& attributeName)
|
const std::string& attributeName)
|
||||||
{
|
{
|
||||||
|
auto result = XML_SUCCESS;
|
||||||
for (auto child = element->FirstChildElement(name); child; child = child->NextSiblingElement(name))
|
for (auto child = element->FirstChildElement(name); child; child = child->NextSiblingElement(name))
|
||||||
query_sound_entry(child, archive, rootPath, soundEntryCollection.emplace_back(), attributeName);
|
result = query_result_merge(
|
||||||
|
result, query_sound_entry(child, archive, rootPath, soundEntryCollection.emplace_back(), attributeName));
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <optional>
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include <glm/glm.hpp>
|
||||||
#include <tinyxml2.h>
|
#include <tinyxml2.h>
|
||||||
|
|
||||||
#include "animation_entry.hpp"
|
#include "animation_entry.hpp"
|
||||||
@@ -19,33 +20,43 @@ namespace game::resource::xml
|
|||||||
tinyxml2::XMLError query_bool_attribute(tinyxml2::XMLElement*, const char*, bool*);
|
tinyxml2::XMLError query_bool_attribute(tinyxml2::XMLElement*, const char*, bool*);
|
||||||
tinyxml2::XMLError query_path_attribute(tinyxml2::XMLElement*, const char*, std::filesystem::path*);
|
tinyxml2::XMLError query_path_attribute(tinyxml2::XMLElement*, const char*, std::filesystem::path*);
|
||||||
tinyxml2::XMLError query_color_attribute(tinyxml2::XMLElement*, const char*, float*);
|
tinyxml2::XMLError query_color_attribute(tinyxml2::XMLElement*, const char*, float*);
|
||||||
|
tinyxml2::XMLError query_ivec2(tinyxml2::XMLElement*, const char*, const char*, glm::ivec2&);
|
||||||
|
tinyxml2::XMLError query_vec2(tinyxml2::XMLElement*, const char*, const char*, glm::vec2&);
|
||||||
|
tinyxml2::XMLError query_vec3(tinyxml2::XMLElement*, const char*, const char*, const char*, glm::vec3&);
|
||||||
|
tinyxml2::XMLError set_bool_attribute(tinyxml2::XMLElement*, const char*, bool);
|
||||||
|
tinyxml2::XMLError set_ivec2_attribute(tinyxml2::XMLElement*, const char*, const char*, const glm::ivec2&);
|
||||||
|
tinyxml2::XMLError set_vec2_attribute(tinyxml2::XMLElement*, const char*, const char*, const glm::vec2&);
|
||||||
|
tinyxml2::XMLError set_vec3_attribute(tinyxml2::XMLElement*, const char*, const char*, const char*,
|
||||||
|
const glm::vec3&);
|
||||||
tinyxml2::XMLError query_float_optional_attribute(tinyxml2::XMLElement* element, const char* attribute,
|
tinyxml2::XMLError query_float_optional_attribute(tinyxml2::XMLElement* element, const char* attribute,
|
||||||
std::optional<float>& value);
|
std::optional<float>& value);
|
||||||
tinyxml2::XMLError query_int_optional_attribute(tinyxml2::XMLElement* element, const char* attribute,
|
tinyxml2::XMLError query_int_optional_attribute(tinyxml2::XMLElement* element, const char* attribute,
|
||||||
std::optional<int>& value);
|
std::optional<int>& value);
|
||||||
|
|
||||||
void query_event_id(tinyxml2::XMLElement* element, const char* name, const Anm2& anm2, int& eventID);
|
tinyxml2::XMLError query_event_id(tinyxml2::XMLElement* element, const char* name, const Anm2& anm2, int& eventID);
|
||||||
void query_layer_id(tinyxml2::XMLElement* element, const char* name, const Anm2& anm2, int& layerID);
|
tinyxml2::XMLError query_layer_id(tinyxml2::XMLElement* element, const char* name, const Anm2& anm2, int& layerID);
|
||||||
void query_null_id(tinyxml2::XMLElement* element, const char* name, const Anm2& anm2, int& nullID);
|
tinyxml2::XMLError query_null_id(tinyxml2::XMLElement* element, const char* name, const Anm2& anm2, int& nullID);
|
||||||
|
|
||||||
void query_anm2(tinyxml2::XMLElement* element, const char* name, const std::string& archive,
|
tinyxml2::XMLError query_anm2(tinyxml2::XMLElement* element, const char* name, const std::string& archive,
|
||||||
const std::string& rootPath, Anm2& anm2, Anm2::Flags flags = {});
|
const std::string& rootPath, Anm2& anm2, Anm2::Flags flags = {});
|
||||||
void query_texture(tinyxml2::XMLElement* element, const char* name, const std::string& archive,
|
tinyxml2::XMLError query_texture(tinyxml2::XMLElement* element, const char* name, const std::string& archive,
|
||||||
const std::string& rootPath, Texture& texture);
|
const std::string& rootPath, Texture& texture);
|
||||||
void query_sound(tinyxml2::XMLElement* element, const char* name, const std::string& archive,
|
tinyxml2::XMLError query_sound(tinyxml2::XMLElement* element, const char* name, const std::string& archive,
|
||||||
const std::string& rootPath, Audio& sound);
|
const std::string& rootPath, Audio& sound);
|
||||||
void query_font(tinyxml2::XMLElement* element, const char* name, const std::string& archive,
|
tinyxml2::XMLError query_font(tinyxml2::XMLElement* element, const char* name, const std::string& archive,
|
||||||
const std::string& rootPath, Font& font);
|
const std::string& rootPath, Font& font);
|
||||||
|
|
||||||
void query_animation_entry(tinyxml2::XMLElement* element, AnimationEntry& animationEntry);
|
tinyxml2::XMLError query_animation_entry(tinyxml2::XMLElement* element, AnimationEntry& animationEntry);
|
||||||
void query_animation_entry_collection(tinyxml2::XMLElement* element, const char* name,
|
tinyxml2::XMLError query_animation_entry_collection(tinyxml2::XMLElement* element, const char* name,
|
||||||
AnimationEntryCollection& animationEntryCollection);
|
AnimationEntryCollection& animationEntryCollection);
|
||||||
|
|
||||||
void query_sound_entry(tinyxml2::XMLElement* element, const std::string& archive, const std::string& rootPath,
|
tinyxml2::XMLError query_sound_entry(tinyxml2::XMLElement* element, const std::string& archive,
|
||||||
SoundEntry& soundEntry, const std::string& attributeName = "Sound");
|
const std::string& rootPath, SoundEntry& soundEntry,
|
||||||
void query_sound_entry_collection(tinyxml2::XMLElement* element, const char* name, const std::string& archive,
|
const std::string& attributeName = "Sound");
|
||||||
const std::string& rootPath, SoundEntryCollection& soundEntryCollection,
|
tinyxml2::XMLError query_sound_entry_collection(tinyxml2::XMLElement* element, const char* name,
|
||||||
const std::string& attributeName = "Sound");
|
const std::string& archive, const std::string& rootPath,
|
||||||
|
SoundEntryCollection& soundEntryCollection,
|
||||||
|
const std::string& attributeName = "Sound");
|
||||||
|
|
||||||
tinyxml2::XMLError document_load(const util::physfs::Path&, tinyxml2::XMLDocument&);
|
tinyxml2::XMLError document_load(const util::physfs::Path&, tinyxml2::XMLDocument&);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ namespace game
|
|||||||
case SELECT:
|
case SELECT:
|
||||||
select.tick();
|
select.tick();
|
||||||
break;
|
break;
|
||||||
case MAIN:
|
case PLAY:
|
||||||
main.tick(resources);
|
play.tick(resources);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -52,7 +52,7 @@ namespace game
|
|||||||
ImGui_ImplSDL3_ProcessEvent(&event);
|
ImGui_ImplSDL3_ProcessEvent(&event);
|
||||||
if (event.type == SDL_EVENT_QUIT)
|
if (event.type == SDL_EVENT_QUIT)
|
||||||
{
|
{
|
||||||
if (type == MAIN) main.exit(resources);
|
if (type == PLAY) play.exit(resources);
|
||||||
isRunning = false;
|
isRunning = false;
|
||||||
}
|
}
|
||||||
if (!isRunning) return;
|
if (!isRunning) return;
|
||||||
@@ -68,30 +68,30 @@ namespace game
|
|||||||
select.update(resources);
|
select.update(resources);
|
||||||
if (select.info.isNewGame || select.info.isContinue)
|
if (select.info.isNewGame || select.info.isContinue)
|
||||||
{
|
{
|
||||||
Main::Game game = select.info.isNewGame ? Main::NEW_GAME : Main::CONTINUE;
|
Play::Game game = select.info.isNewGame ? Play::NEW_GAME : Play::CONTINUE;
|
||||||
if (game == Main::NEW_GAME) resources.character_save_set(select.characterIndex, resource::xml::Save());
|
if (game == Play::NEW_GAME) resources.character_save_set(select.characterIndex, resource::xml::Save());
|
||||||
|
|
||||||
main.set(resources, select.characterIndex, game);
|
play.set(resources, select.characterIndex, game);
|
||||||
type = MAIN;
|
type = PLAY;
|
||||||
|
|
||||||
select.info.isNewGame = false;
|
select.info.isNewGame = false;
|
||||||
select.info.isContinue = false;
|
select.info.isContinue = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MAIN:
|
case PLAY:
|
||||||
main.update(resources);
|
play.update(resources);
|
||||||
if (main.menu.configuration.isGoToSelect)
|
if (play.menu.settingsMenu.isGoToSelect)
|
||||||
{
|
{
|
||||||
main.exit(resources);
|
play.exit(resources);
|
||||||
type = SELECT;
|
type = SELECT;
|
||||||
main.menu.configuration.isGoToSelect = false;
|
play.menu.settingsMenu.isGoToSelect = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto isHideCursor = type == MAIN;
|
auto isHideCursor = type == PLAY;
|
||||||
if (isHideCursor != isCursorHidden)
|
if (isHideCursor != isCursorHidden)
|
||||||
{
|
{
|
||||||
if (isHideCursor)
|
if (isHideCursor)
|
||||||
@@ -104,6 +104,8 @@ namespace game
|
|||||||
|
|
||||||
void State::render()
|
void State::render()
|
||||||
{
|
{
|
||||||
|
auto& color =
|
||||||
|
resources.settings.isUseCharacterColor && type == PLAY ? play.character.data.color : resources.settings.color;
|
||||||
auto windowSize = resources.settings.windowSize;
|
auto windowSize = resources.settings.windowSize;
|
||||||
#ifndef __EMSCRIPTEN__
|
#ifndef __EMSCRIPTEN__
|
||||||
SDL_GetWindowSize(window, &windowSize.x, &windowSize.y);
|
SDL_GetWindowSize(window, &windowSize.x, &windowSize.y);
|
||||||
@@ -111,7 +113,7 @@ namespace game
|
|||||||
|
|
||||||
canvas.bind();
|
canvas.bind();
|
||||||
canvas.size_set(windowSize);
|
canvas.size_set(windowSize);
|
||||||
canvas.clear(vec4(resources.settings.color, 1.0f));
|
canvas.clear(vec4(color, 1.0f));
|
||||||
canvas.unbind();
|
canvas.unbind();
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
@@ -119,8 +121,8 @@ namespace game
|
|||||||
case SELECT:
|
case SELECT:
|
||||||
select.render(resources, canvas);
|
select.render(resources, canvas);
|
||||||
break;
|
break;
|
||||||
case MAIN:
|
case PLAY:
|
||||||
main.render(resources, canvas);
|
play.render(resources, canvas);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
#include <SDL3/SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
|
|
||||||
#include "canvas.hpp"
|
#include "render/canvas.hpp"
|
||||||
#include "resources.hpp"
|
#include "resources.hpp"
|
||||||
|
|
||||||
#include "state/main.hpp"
|
#include "state/play.hpp"
|
||||||
#include "state/select.hpp"
|
#include "state/select.hpp"
|
||||||
|
|
||||||
#include "entity/cursor.hpp"
|
#include "entity/cursor.hpp"
|
||||||
@@ -22,7 +22,7 @@ namespace game
|
|||||||
|
|
||||||
enum Type
|
enum Type
|
||||||
{
|
{
|
||||||
MAIN,
|
PLAY,
|
||||||
SELECT
|
SELECT
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ namespace game
|
|||||||
|
|
||||||
Resources resources;
|
Resources resources;
|
||||||
|
|
||||||
state::Main main;
|
state::Play play;
|
||||||
state::Select select;
|
state::Select select;
|
||||||
|
|
||||||
void tick();
|
void tick();
|
||||||
|
|||||||
@@ -1,194 +0,0 @@
|
|||||||
#include "inventory.hpp"
|
|
||||||
|
|
||||||
#include <cmath>
|
|
||||||
#include <format>
|
|
||||||
#include <ranges>
|
|
||||||
|
|
||||||
#include "../../util/color.hpp"
|
|
||||||
#include "../../util/imgui.hpp"
|
|
||||||
#include "../../util/imgui/widget.hpp"
|
|
||||||
#include "../../util/math.hpp"
|
|
||||||
|
|
||||||
using namespace game::util;
|
|
||||||
using namespace game::util::imgui;
|
|
||||||
using namespace game::entity;
|
|
||||||
using namespace game::resource;
|
|
||||||
using namespace glm;
|
|
||||||
|
|
||||||
namespace game::state::main
|
|
||||||
{
|
|
||||||
void Inventory::tick()
|
|
||||||
{
|
|
||||||
for (auto& [i, actor] : actors)
|
|
||||||
actor.tick();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Inventory::update(Resources& resources, ItemManager& itemManager, entity::Character& character)
|
|
||||||
{
|
|
||||||
auto& schema = character.data.itemSchema;
|
|
||||||
|
|
||||||
if (!itemManager.returnItemIDs.empty())
|
|
||||||
{
|
|
||||||
for (auto& id : itemManager.returnItemIDs)
|
|
||||||
values[id]++;
|
|
||||||
itemManager.returnItemIDs.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ImGui::BeginChild("##Inventory Child"))
|
|
||||||
{
|
|
||||||
auto cursorPos = ImGui::GetCursorPos();
|
|
||||||
auto cursorStartX = ImGui::GetCursorPosX();
|
|
||||||
|
|
||||||
auto size = ImVec2(SIZE, SIZE);
|
|
||||||
|
|
||||||
for (int i = 0; i < (int)schema.items.size(); i++)
|
|
||||||
{
|
|
||||||
auto& item = schema.items[i];
|
|
||||||
auto& quantity = values[i];
|
|
||||||
auto& category = schema.categories[item.categoryID];
|
|
||||||
auto& calories = item.calories;
|
|
||||||
auto& digestionBonus = item.digestionBonus;
|
|
||||||
auto& eatSpeedBonus = item.eatSpeedBonus;
|
|
||||||
auto& rarity = schema.rarities[item.rarityID];
|
|
||||||
|
|
||||||
quantity = glm::clamp(0, quantity, schema.quantityMax);
|
|
||||||
if (rarity.isHidden && quantity <= 0) continue;
|
|
||||||
|
|
||||||
ImGui::PushID(i);
|
|
||||||
|
|
||||||
ImGui::SetCursorPos(cursorPos);
|
|
||||||
auto cursorScreenPos = ImGui::GetCursorScreenPos();
|
|
||||||
|
|
||||||
if (!actors.contains(i))
|
|
||||||
{
|
|
||||||
actors[i] = Actor(schema.anm2s[i], {}, Actor::SET);
|
|
||||||
rects[i] = actors[i].rect();
|
|
||||||
}
|
|
||||||
auto& rect = rects[i];
|
|
||||||
auto rectSize = vec2(rect.z, rect.w);
|
|
||||||
|
|
||||||
auto previewScale = (size.x <= 0.0f || size.y <= 0.0f || rectSize.x <= 0.0f || rectSize.y <= 0.0f ||
|
|
||||||
!std::isfinite(rectSize.x) || !std::isfinite(rectSize.y))
|
|
||||||
? 0.0f
|
|
||||||
: std::min(size.x / rectSize.x, size.y / rectSize.y);
|
|
||||||
|
|
||||||
auto previewSize = rectSize * previewScale;
|
|
||||||
auto canvasSize = ivec2(std::max(1.0f, previewSize.x), std::max(1.0f, previewSize.y));
|
|
||||||
if (!canvases.contains(i)) canvases.emplace((int)i, Canvas(canvasSize, Canvas::FLIP));
|
|
||||||
auto& canvas = canvases[i];
|
|
||||||
canvas.zoom = math::to_percent(previewScale);
|
|
||||||
canvas.pan = vec2(rect.x, rect.y);
|
|
||||||
canvas.bind();
|
|
||||||
canvas.size_set(canvasSize);
|
|
||||||
canvas.clear();
|
|
||||||
|
|
||||||
actors[i].render(resources.shaders[shader::TEXTURE], resources.shaders[shader::RECT], canvas);
|
|
||||||
canvas.unbind();
|
|
||||||
|
|
||||||
ImGui::BeginDisabled(quantity < 1);
|
|
||||||
if (WIDGET_FX(ImGui::ImageButton("##Image Button", canvas.texture, size, ImVec2(), ImVec2(1, 1), ImVec4(),
|
|
||||||
quantity <= 0 ? ImVec4(0, 0, 0, 1) : ImVec4(1, 1, 1, 1))) &&
|
|
||||||
quantity > 0)
|
|
||||||
{
|
|
||||||
if (category.isEdible)
|
|
||||||
{
|
|
||||||
if (itemManager.items.size() + 1 >= ItemManager::LIMIT)
|
|
||||||
character.data.itemSchema.sounds.dispose.play();
|
|
||||||
else
|
|
||||||
{
|
|
||||||
character.data.itemSchema.sounds.summon.play();
|
|
||||||
itemManager.queuedItemIDs.emplace_back(i);
|
|
||||||
quantity--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (item.isToggleSpritesheet)
|
|
||||||
{
|
|
||||||
character.spritesheet_set(character.spritesheetType == Character::NORMAL ? Character::ALTERNATE
|
|
||||||
: Character::NORMAL);
|
|
||||||
character.data.alternateSpritesheet.sound.play();
|
|
||||||
quantity--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::EndDisabled();
|
|
||||||
|
|
||||||
if (ImGui::BeginItemTooltip())
|
|
||||||
{
|
|
||||||
if (quantity > 0)
|
|
||||||
{
|
|
||||||
ImGui::PushFont(ImGui::GetFont(), Font::BIG);
|
|
||||||
|
|
||||||
ImGui::Text("%s (x%i)", item.name.c_str(), quantity);
|
|
||||||
|
|
||||||
ImGui::Separator();
|
|
||||||
|
|
||||||
ImGui::PopFont();
|
|
||||||
|
|
||||||
ImGui::PushStyleColor(ImGuiCol_Text, ImGui::GetColorU32(imgui::to_imvec4(color::GRAY)));
|
|
||||||
|
|
||||||
ImGui::Text("-- %s (%s) --", category.name.c_str(), rarity.name.c_str());
|
|
||||||
if (item.flavorID.has_value()) ImGui::Text("Flavor: %s", schema.flavors[*item.flavorID].name.c_str());
|
|
||||||
if (calories.has_value()) ImGui::Text("%0.0f kcal", *calories);
|
|
||||||
if (digestionBonus.has_value())
|
|
||||||
{
|
|
||||||
if (*digestionBonus > 0)
|
|
||||||
ImGui::Text("Digestion Rate Bonus: +%0.2f%% / sec", *digestionBonus * 60.0f);
|
|
||||||
else if (digestionBonus < 0)
|
|
||||||
ImGui::Text("Digestion Rate Penalty: %0.2f%% / sec", *digestionBonus * 60.0f);
|
|
||||||
}
|
|
||||||
if (eatSpeedBonus.has_value())
|
|
||||||
{
|
|
||||||
if (*eatSpeedBonus > 0)
|
|
||||||
ImGui::Text("Eat Speed Bonus: +%0.2f%% / sec", *eatSpeedBonus);
|
|
||||||
else if (eatSpeedBonus < 0)
|
|
||||||
ImGui::Text("Eat Speed Penalty: %0.2f%% / sec", *eatSpeedBonus);
|
|
||||||
}
|
|
||||||
ImGui::PopStyleColor();
|
|
||||||
|
|
||||||
ImGui::Separator();
|
|
||||||
ImGui::TextUnformatted(item.description.c_str());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ImGui::PushFont(ImGui::GetFont(), Font::BIG);
|
|
||||||
ImGui::TextUnformatted("???");
|
|
||||||
ImGui::PopFont();
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::EndTooltip();
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::PushFont(ImGui::GetFont(), Font::BIG);
|
|
||||||
|
|
||||||
auto text = std::format("x{}", quantity);
|
|
||||||
auto textPos = ImVec2(cursorScreenPos.x + size.x - ImGui::CalcTextSize(text.c_str()).x,
|
|
||||||
cursorScreenPos.y + size.y - ImGui::GetTextLineHeightWithSpacing());
|
|
||||||
ImGui::GetWindowDrawList()->AddText(textPos, ImGui::GetColorU32(ImGui::GetStyleColorVec4(ImGuiCol_Text)),
|
|
||||||
text.c_str());
|
|
||||||
ImGui::PopFont();
|
|
||||||
|
|
||||||
auto increment = ImGui::GetItemRectSize().x + ImGui::GetStyle().ItemSpacing.x;
|
|
||||||
cursorPos.x += increment;
|
|
||||||
|
|
||||||
if (cursorPos.x + increment > ImGui::GetContentRegionAvail().x)
|
|
||||||
{
|
|
||||||
cursorPos.x = cursorStartX;
|
|
||||||
cursorPos.y += increment;
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::PopID();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count() == 0) ImGui::Text("Check the \"Play\" tab to earn rewards!");
|
|
||||||
}
|
|
||||||
ImGui::EndChild();
|
|
||||||
}
|
|
||||||
|
|
||||||
int Inventory::count()
|
|
||||||
{
|
|
||||||
int count{};
|
|
||||||
for (auto& [type, quantity] : values)
|
|
||||||
count += quantity;
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "main.hpp"
|
#include "play.hpp"
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
#include <imgui_impl_opengl3.h>
|
#include <imgui_impl_opengl3.h>
|
||||||
@@ -11,12 +12,12 @@
|
|||||||
|
|
||||||
using namespace game::resource;
|
using namespace game::resource;
|
||||||
using namespace game::util;
|
using namespace game::util;
|
||||||
using namespace game::state::main;
|
using namespace game::state::play;
|
||||||
using namespace glm;
|
using namespace glm;
|
||||||
|
|
||||||
namespace game::state
|
namespace game::state
|
||||||
{
|
{
|
||||||
World::Focus Main::focus_get()
|
World::Focus Play::focus_get()
|
||||||
{
|
{
|
||||||
if (!isWindows) return World::CENTER;
|
if (!isWindows) return World::CENTER;
|
||||||
|
|
||||||
@@ -26,7 +27,7 @@ namespace game::state
|
|||||||
: World::CENTER;
|
: World::CENTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Main::set(Resources& resources, int selectedCharacterIndex, enum Game game)
|
void Play::set(Resources& resources, int selectedCharacterIndex, enum Game game)
|
||||||
{
|
{
|
||||||
auto& data = resources.character_get(selectedCharacterIndex);
|
auto& data = resources.character_get(selectedCharacterIndex);
|
||||||
auto& saveData = data.save;
|
auto& saveData = data.save;
|
||||||
@@ -34,6 +35,8 @@ namespace game::state
|
|||||||
auto& dialogue = data.dialogue;
|
auto& dialogue = data.dialogue;
|
||||||
auto& menuSchema = data.menuSchema;
|
auto& menuSchema = data.menuSchema;
|
||||||
this->characterIndex = selectedCharacterIndex;
|
this->characterIndex = selectedCharacterIndex;
|
||||||
|
cheatCodeIndex = 0;
|
||||||
|
cheatCodeStartTime = 0.0;
|
||||||
|
|
||||||
character =
|
character =
|
||||||
entity::Character(data, vec2(World::BOUNDS.x + World::BOUNDS.z * 0.5f, World::BOUNDS.w - World::BOUNDS.y));
|
entity::Character(data, vec2(World::BOUNDS.x + World::BOUNDS.z * 0.5f, World::BOUNDS.w - World::BOUNDS.y));
|
||||||
@@ -55,6 +58,7 @@ namespace game::state
|
|||||||
characterManager = CharacterManager{};
|
characterManager = CharacterManager{};
|
||||||
|
|
||||||
cursor = entity::Cursor(character.data.cursorSchema.anm2);
|
cursor = entity::Cursor(character.data.cursorSchema.anm2);
|
||||||
|
cursor.interactTypeID = character.data.interactTypeNames.empty() ? -1 : 0;
|
||||||
|
|
||||||
menu.inventory = Inventory{};
|
menu.inventory = Inventory{};
|
||||||
for (auto& [id, quantity] : saveData.inventory)
|
for (auto& [id, quantity] : saveData.inventory)
|
||||||
@@ -76,19 +80,20 @@ namespace game::state
|
|||||||
|
|
||||||
imgui::style::rounding_set(menuSchema.rounding);
|
imgui::style::rounding_set(menuSchema.rounding);
|
||||||
imgui::widget::sounds_set(&menuSchema.sounds.hover, &menuSchema.sounds.select);
|
imgui::widget::sounds_set(&menuSchema.sounds.hover, &menuSchema.sounds.select);
|
||||||
|
menu.color_set_check(resources, character);
|
||||||
|
|
||||||
menu.play = Play(character);
|
menu.skillCheck = SkillCheck(character);
|
||||||
menu.play.totalPlays = saveData.totalPlays;
|
menu.skillCheck.totalPlays = saveData.totalPlays;
|
||||||
menu.play.highScore = saveData.highScore;
|
menu.skillCheck.highScore = saveData.highScore;
|
||||||
menu.play.bestCombo = saveData.bestCombo;
|
menu.skillCheck.bestCombo = saveData.bestCombo;
|
||||||
menu.play.gradeCounts = saveData.gradeCounts;
|
menu.skillCheck.gradeCounts = saveData.gradeCounts;
|
||||||
menu.play.isHighScoreAchieved = saveData.highScore > 0 ? true : false;
|
menu.skillCheck.isHighScoreAchieved = saveData.highScore > 0 ? true : false;
|
||||||
|
|
||||||
menu.isChat = character.data.dialogue.help.is_valid() || character.data.dialogue.random.is_valid();
|
menu.isChat = character.data.dialogue.help.is_valid() || character.data.dialogue.random.is_valid();
|
||||||
|
|
||||||
text.entry = nullptr;
|
text.entry = nullptr;
|
||||||
text.isEnabled = false;
|
text.isEnabled = false;
|
||||||
|
|
||||||
|
menu.isCheats = false;
|
||||||
isPostgame = saveData.isPostgame;
|
isPostgame = saveData.isPostgame;
|
||||||
if (character.stage_get() >= character.stage_max_get()) isPostgame = true;
|
if (character.stage_get() >= character.stage_max_get()) isPostgame = true;
|
||||||
if (isPostgame) menu.isCheats = true;
|
if (isPostgame) menu.isCheats = true;
|
||||||
@@ -107,18 +112,34 @@ namespace game::state
|
|||||||
character.queue_play({.animation = dialogue.start.animation, .isInterruptible = false});
|
character.queue_play({.animation = dialogue.start.animation, .isInterruptible = false});
|
||||||
character.tick();
|
character.tick();
|
||||||
isStart = true;
|
isStart = true;
|
||||||
|
isStartBegin = false;
|
||||||
|
isStartEnd = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isPostgame)
|
||||||
|
{
|
||||||
|
isEnd = true;
|
||||||
|
isEndBegin = true;
|
||||||
|
isEndEnd = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
isEnd = false;
|
||||||
|
isEndBegin = false;
|
||||||
|
isEndEnd = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Main::exit(Resources& resources)
|
void Play::exit(Resources& resources)
|
||||||
{
|
{
|
||||||
|
imgui::style::color_set(resources.settings.color);
|
||||||
imgui::style::rounding_set();
|
imgui::style::rounding_set();
|
||||||
imgui::widget::sounds_set(nullptr, nullptr);
|
imgui::widget::sounds_set(nullptr, nullptr);
|
||||||
ImGui::GetIO().FontDefault = resources.font.get();
|
ImGui::GetIO().FontDefault = resources.font.get();
|
||||||
save(resources);
|
save(resources);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Main::tick(Resources&)
|
void Play::tick(Resources&)
|
||||||
{
|
{
|
||||||
character.tick();
|
character.tick();
|
||||||
cursor.tick();
|
cursor.tick();
|
||||||
@@ -130,11 +151,57 @@ namespace game::state
|
|||||||
item.tick();
|
item.tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Main::update(Resources& resources)
|
void Play::update(Resources& resources)
|
||||||
{
|
{
|
||||||
|
static constexpr std::array<ImGuiKey, 10> CHEAT_CODE = {
|
||||||
|
ImGuiKey_UpArrow, ImGuiKey_UpArrow, ImGuiKey_DownArrow, ImGuiKey_DownArrow, ImGuiKey_LeftArrow,
|
||||||
|
ImGuiKey_RightArrow, ImGuiKey_LeftArrow, ImGuiKey_RightArrow, ImGuiKey_B, ImGuiKey_A};
|
||||||
|
static constexpr std::array<ImGuiKey, 6> CHEAT_INPUT_KEYS = {
|
||||||
|
ImGuiKey_UpArrow, ImGuiKey_DownArrow, ImGuiKey_LeftArrow, ImGuiKey_RightArrow, ImGuiKey_B, ImGuiKey_A};
|
||||||
|
static constexpr auto CHEAT_CODE_INPUT_TIME_SECONDS = 5.0;
|
||||||
|
|
||||||
auto focus = focus_get();
|
auto focus = focus_get();
|
||||||
auto& dialogue = character.data.dialogue;
|
auto& dialogue = character.data.dialogue;
|
||||||
|
|
||||||
|
if (!menu.isCheats)
|
||||||
|
{
|
||||||
|
for (auto key : CHEAT_INPUT_KEYS)
|
||||||
|
{
|
||||||
|
if (!ImGui::IsKeyPressed(key, false)) continue;
|
||||||
|
|
||||||
|
if (key == CHEAT_CODE[cheatCodeIndex])
|
||||||
|
{
|
||||||
|
cheatCodeIndex++;
|
||||||
|
cheatCodeStartTime = ImGui::GetTime();
|
||||||
|
}
|
||||||
|
else if (key == CHEAT_CODE[0])
|
||||||
|
{
|
||||||
|
cheatCodeIndex = 1;
|
||||||
|
cheatCodeStartTime = ImGui::GetTime();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cheatCodeIndex = 0;
|
||||||
|
cheatCodeStartTime = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cheatCodeIndex >= (int)CHEAT_CODE.size())
|
||||||
|
{
|
||||||
|
menu.isCheats = true;
|
||||||
|
cheatCodeIndex = 0;
|
||||||
|
cheatCodeStartTime = 0.0;
|
||||||
|
toasts.push("Cheats unlocked!");
|
||||||
|
character.data.menuSchema.sounds.cheatsActivated.play();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cheatCodeIndex > 0 && (ImGui::GetTime() - cheatCodeStartTime > CHEAT_CODE_INPUT_TIME_SECONDS))
|
||||||
|
{
|
||||||
|
cheatCodeIndex = 0;
|
||||||
|
cheatCodeStartTime = 0.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isWindows)
|
if (isWindows)
|
||||||
{
|
{
|
||||||
menu.update(resources, itemManager, character, cursor, text, worldCanvas);
|
menu.update(resources, itemManager, character, cursor, text, worldCanvas);
|
||||||
@@ -199,6 +266,7 @@ namespace game::state
|
|||||||
isEndEnd = true;
|
isEndEnd = true;
|
||||||
isEnd = false;
|
isEnd = false;
|
||||||
isPostgame = true;
|
isPostgame = true;
|
||||||
|
menu.isCheats = true;
|
||||||
world.character_focus(character, worldCanvas, focus_get());
|
world.character_focus(character, worldCanvas, focus_get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -211,15 +279,15 @@ namespace game::state
|
|||||||
cursor.update();
|
cursor.update();
|
||||||
world.update(character, cursor, worldCanvas, focus);
|
world.update(character, cursor, worldCanvas, focus);
|
||||||
|
|
||||||
if (autosaveTime += ImGui::GetIO().DeltaTime; autosaveTime > AUTOSAVE_TIME || menu.configuration.isSave)
|
if (autosaveTime += ImGui::GetIO().DeltaTime; autosaveTime > AUTOSAVE_TIME || menu.settingsMenu.isSave)
|
||||||
{
|
{
|
||||||
save(resources);
|
save(resources);
|
||||||
autosaveTime = 0;
|
autosaveTime = 0;
|
||||||
menu.configuration.isSave = false;
|
menu.settingsMenu.isSave = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Main::render(Resources& resources, Canvas& canvas)
|
void Play::render(Resources& resources, Canvas& canvas)
|
||||||
{
|
{
|
||||||
auto& textureShader = resources.shaders[shader::TEXTURE];
|
auto& textureShader = resources.shaders[shader::TEXTURE];
|
||||||
auto& rectShader = resources.shaders[shader::RECT];
|
auto& rectShader = resources.shaders[shader::RECT];
|
||||||
@@ -256,7 +324,7 @@ namespace game::state
|
|||||||
canvas.unbind();
|
canvas.unbind();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Main::save(Resources& resources)
|
void Play::save(Resources& resources)
|
||||||
{
|
{
|
||||||
resource::xml::Save save;
|
resource::xml::Save save;
|
||||||
|
|
||||||
@@ -270,10 +338,10 @@ namespace game::state
|
|||||||
save.digestionTimer = character.digestionTimer;
|
save.digestionTimer = character.digestionTimer;
|
||||||
save.totalCaloriesConsumed = character.totalCaloriesConsumed;
|
save.totalCaloriesConsumed = character.totalCaloriesConsumed;
|
||||||
save.totalFoodItemsEaten = character.totalFoodItemsEaten;
|
save.totalFoodItemsEaten = character.totalFoodItemsEaten;
|
||||||
save.totalPlays = menu.play.totalPlays;
|
save.totalPlays = menu.skillCheck.totalPlays;
|
||||||
save.highScore = menu.play.highScore;
|
save.highScore = menu.skillCheck.highScore;
|
||||||
save.bestCombo = menu.play.bestCombo;
|
save.bestCombo = menu.skillCheck.bestCombo;
|
||||||
save.gradeCounts = menu.play.gradeCounts;
|
save.gradeCounts = menu.skillCheck.gradeCounts;
|
||||||
save.isPostgame = isPostgame;
|
save.isPostgame = isPostgame;
|
||||||
save.isAlternateSpritesheet = character.spritesheetType == entity::Character::ALTERNATE;
|
save.isAlternateSpritesheet = character.spritesheetType == entity::Character::ALTERNATE;
|
||||||
|
|
||||||
@@ -2,19 +2,19 @@
|
|||||||
|
|
||||||
#include "../resources.hpp"
|
#include "../resources.hpp"
|
||||||
|
|
||||||
#include "main/area_manager.hpp"
|
#include "play/area_manager.hpp"
|
||||||
#include "main/character_manager.hpp"
|
#include "play/character_manager.hpp"
|
||||||
#include "main/info.hpp"
|
#include "play/info.hpp"
|
||||||
#include "main/item_manager.hpp"
|
#include "play/item_manager.hpp"
|
||||||
#include "main/menu.hpp"
|
#include "play/menu.hpp"
|
||||||
#include "main/text.hpp"
|
#include "play/text.hpp"
|
||||||
#include "main/toasts.hpp"
|
#include "play/toasts.hpp"
|
||||||
#include "main/tools.hpp"
|
#include "play/tools.hpp"
|
||||||
#include "main/world.hpp"
|
#include "play/world.hpp"
|
||||||
|
|
||||||
namespace game::state
|
namespace game::state
|
||||||
{
|
{
|
||||||
class Main
|
class Play
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static constexpr auto AUTOSAVE_TIME = 30.0f;
|
static constexpr auto AUTOSAVE_TIME = 30.0f;
|
||||||
@@ -28,20 +28,22 @@ namespace game::state
|
|||||||
entity::Character character;
|
entity::Character character;
|
||||||
entity::Cursor cursor;
|
entity::Cursor cursor;
|
||||||
|
|
||||||
main::Info info;
|
play::Info info;
|
||||||
main::Menu menu;
|
play::Menu menu;
|
||||||
main::Tools tools;
|
play::Tools tools;
|
||||||
main::Text text;
|
play::Text text;
|
||||||
main::World world;
|
play::World world;
|
||||||
main::Toasts toasts;
|
play::Toasts toasts;
|
||||||
main::ItemManager itemManager{};
|
play::ItemManager itemManager{};
|
||||||
main::CharacterManager characterManager{};
|
play::CharacterManager characterManager{};
|
||||||
main::AreaManager areaManager{};
|
play::AreaManager areaManager{};
|
||||||
|
|
||||||
int characterIndex{};
|
int characterIndex{};
|
||||||
int areaIndex{};
|
int areaIndex{};
|
||||||
|
|
||||||
float autosaveTime{};
|
float autosaveTime{};
|
||||||
|
int cheatCodeIndex{};
|
||||||
|
double cheatCodeStartTime{};
|
||||||
|
|
||||||
bool isWindows{true};
|
bool isWindows{true};
|
||||||
|
|
||||||
@@ -55,15 +57,15 @@ namespace game::state
|
|||||||
|
|
||||||
bool isPostgame{};
|
bool isPostgame{};
|
||||||
|
|
||||||
Canvas worldCanvas{main::World::SIZE};
|
Canvas worldCanvas{play::World::SIZE};
|
||||||
|
|
||||||
Main() = default;
|
Play() = default;
|
||||||
void set(Resources&, int characterIndex, Game = CONTINUE);
|
void set(Resources&, int characterIndex, Game = CONTINUE);
|
||||||
void exit(Resources& resources);
|
void exit(Resources& resources);
|
||||||
void update(Resources&);
|
void update(Resources&);
|
||||||
void tick(Resources&);
|
void tick(Resources&);
|
||||||
void render(Resources&, Canvas&);
|
void render(Resources&, Canvas&);
|
||||||
void save(Resources&);
|
void save(Resources&);
|
||||||
main::World::Focus focus_get();
|
play::World::Focus focus_get();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
#include "play.hpp"
|
#include "skill_check.hpp"
|
||||||
|
|
||||||
#include <imgui_internal.h>
|
#include <imgui_internal.h>
|
||||||
|
|
||||||
#include "../../util/imgui.hpp"
|
#include "../../../util/imgui.hpp"
|
||||||
#include "../../util/imgui/widget.hpp"
|
#include "../../../util/imgui/widget.hpp"
|
||||||
#include "../../util/math.hpp"
|
#include "../../../util/math.hpp"
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <format>
|
#include <format>
|
||||||
@@ -15,13 +15,13 @@ using namespace game::entity;
|
|||||||
using namespace game::resource;
|
using namespace game::resource;
|
||||||
using namespace glm;
|
using namespace glm;
|
||||||
|
|
||||||
namespace game::state::main
|
namespace game::state::play
|
||||||
{
|
{
|
||||||
float Play::accuracy_score_get(entity::Character& character)
|
float SkillCheck::accuracy_score_get(entity::Character& character)
|
||||||
{
|
{
|
||||||
if (totalPlays == 0) return 0.0f;
|
if (totalPlays == 0) return 0.0f;
|
||||||
|
|
||||||
auto& schema = character.data.playSchema;
|
auto& schema = character.data.skillCheckSchema;
|
||||||
|
|
||||||
float combinedWeight{};
|
float combinedWeight{};
|
||||||
|
|
||||||
@@ -34,9 +34,9 @@ namespace game::state::main
|
|||||||
return glm::clamp(0.0f, math::to_percent(combinedWeight / totalPlays), 100.0f);
|
return glm::clamp(0.0f, math::to_percent(combinedWeight / totalPlays), 100.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
Play::Challenge Play::challenge_generate(entity::Character& character)
|
SkillCheck::Challenge SkillCheck::challenge_generate(entity::Character& character)
|
||||||
{
|
{
|
||||||
auto& schema = character.data.playSchema;
|
auto& schema = character.data.skillCheckSchema;
|
||||||
|
|
||||||
Challenge newChallenge;
|
Challenge newChallenge;
|
||||||
|
|
||||||
@@ -61,26 +61,26 @@ namespace game::state::main
|
|||||||
return newChallenge;
|
return newChallenge;
|
||||||
}
|
}
|
||||||
|
|
||||||
Play::Play(entity::Character& character) { challenge = challenge_generate(character); }
|
SkillCheck::SkillCheck(entity::Character& character) { challenge = challenge_generate(character); }
|
||||||
|
|
||||||
void Play::tick()
|
void SkillCheck::tick()
|
||||||
{
|
{
|
||||||
for (auto& [i, actor] : itemActors)
|
for (auto& [i, actor] : itemActors)
|
||||||
actor.tick();
|
actor.tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Play::update(Resources& resources, entity::Character& character, Inventory& inventory, Text& text)
|
void SkillCheck::update(Resources& resources, entity::Character& character, Inventory& inventory, Text& text)
|
||||||
{
|
{
|
||||||
static constexpr auto BG_COLOR_MULTIPLIER = 0.5f;
|
static constexpr auto BG_COLOR_MULTIPLIER = 0.5f;
|
||||||
static constexpr ImVec4 LINE_COLOR = ImVec4(1, 1, 1, 1);
|
static constexpr ImVec4 LINE_COLOR = ImVec4(1, 1, 1, 1);
|
||||||
static constexpr ImVec4 PERFECT_COLOR = ImVec4(1, 1, 1, 0.50);
|
static constexpr ImVec4 PERFECT_COLOR = ImVec4(1, 1, 1, 0.50);
|
||||||
static constexpr auto LINE_HEIGHT = 2.0f;
|
static constexpr auto LINE_HEIGHT = 5.0f;
|
||||||
static constexpr auto LINE_WIDTH_BONUS = 10.0f;
|
static constexpr auto LINE_WIDTH_BONUS = 10.0f;
|
||||||
static constexpr auto TOAST_MESSAGE_SPEED = 1.0f;
|
static constexpr auto TOAST_MESSAGE_SPEED = 1.0f;
|
||||||
static constexpr auto ITEM_FALL_GRAVITY = 2400.0f;
|
static constexpr auto ITEM_FALL_GRAVITY = 2400.0f;
|
||||||
|
|
||||||
auto& dialogue = character.data.dialogue;
|
auto& dialogue = character.data.dialogue;
|
||||||
auto& schema = character.data.playSchema;
|
auto& schema = character.data.skillCheckSchema;
|
||||||
auto& itemSchema = character.data.itemSchema;
|
auto& itemSchema = character.data.itemSchema;
|
||||||
auto& style = ImGui::GetStyle();
|
auto& style = ImGui::GetStyle();
|
||||||
auto drawList = ImGui::GetWindowDrawList();
|
auto drawList = ImGui::GetWindowDrawList();
|
||||||
@@ -202,7 +202,7 @@ namespace game::state::main
|
|||||||
auto barButtonSize = ImVec2(barMax.x - barMin.x, barMax.y - barMin.y);
|
auto barButtonSize = ImVec2(barMax.x - barMin.x, barMax.y - barMin.y);
|
||||||
|
|
||||||
if (ImGui::IsKeyPressed(ImGuiKey_Space) ||
|
if (ImGui::IsKeyPressed(ImGuiKey_Space) ||
|
||||||
WIDGET_FX(ImGui::InvisibleButton("##PlayBar", barButtonSize, ImGuiButtonFlags_PressedOnClick)))
|
WIDGET_FX(ImGui::InvisibleButton("##SkillCheckBar", barButtonSize, ImGuiButtonFlags_PressedOnClick)))
|
||||||
{
|
{
|
||||||
int gradeID{};
|
int gradeID{};
|
||||||
|
|
||||||
@@ -234,7 +234,7 @@ namespace game::state::main
|
|||||||
schema.sounds.rewardScore.play();
|
schema.sounds.rewardScore.play();
|
||||||
isRewardScoreAchieved = true;
|
isRewardScoreAchieved = true;
|
||||||
|
|
||||||
for (auto& itemID : itemSchema.rewardItemPool)
|
for (auto& itemID : itemSchema.skillCheckRewardItemPool)
|
||||||
{
|
{
|
||||||
inventory.values[itemID]++;
|
inventory.values[itemID]++;
|
||||||
if (!itemActors.contains(itemID))
|
if (!itemActors.contains(itemID))
|
||||||
@@ -335,8 +335,8 @@ namespace game::state::main
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
score = 0;
|
score = 0;
|
||||||
|
combo = 0;
|
||||||
if (isHighScoreAchieved) schema.sounds.highScoreLoss.play();
|
if (isHighScoreAchieved) schema.sounds.highScoreLoss.play();
|
||||||
if (highScore > 0) isHighScoreAchieved = true;
|
if (highScore > 0) isHighScoreAchieved = true;
|
||||||
isRewardScoreAchieved = false;
|
isRewardScoreAchieved = false;
|
||||||
@@ -1,21 +1,21 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../../canvas.hpp"
|
#include "../../../render/canvas.hpp"
|
||||||
#include "../../entity/actor.hpp"
|
#include "../../../entity/actor.hpp"
|
||||||
#include "../../entity/character.hpp"
|
#include "../../../entity/character.hpp"
|
||||||
#include "../../resources.hpp"
|
#include "../../../resources.hpp"
|
||||||
|
|
||||||
#include "inventory.hpp"
|
#include "../inventory.hpp"
|
||||||
#include "text.hpp"
|
#include "../text.hpp"
|
||||||
|
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace game::state::main
|
namespace game::state::play
|
||||||
{
|
{
|
||||||
class Play
|
class SkillCheck
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -77,8 +77,8 @@ namespace game::state::main
|
|||||||
std::unordered_map<int, glm::vec4> itemRects{};
|
std::unordered_map<int, glm::vec4> itemRects{};
|
||||||
std::unordered_map<int, Canvas> itemCanvases{};
|
std::unordered_map<int, Canvas> itemCanvases{};
|
||||||
|
|
||||||
Play() = default;
|
SkillCheck() = default;
|
||||||
Play(entity::Character&);
|
SkillCheck(entity::Character&);
|
||||||
Challenge challenge_generate(entity::Character&);
|
Challenge challenge_generate(entity::Character&);
|
||||||
void tick();
|
void tick();
|
||||||
void update(Resources&, entity::Character&, Inventory&, Text&);
|
void update(Resources&, entity::Character&, Inventory&, Text&);
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
using namespace game::resource;
|
using namespace game::resource;
|
||||||
using namespace game::util;
|
using namespace game::util;
|
||||||
|
|
||||||
namespace game::state::main
|
namespace game::state::play
|
||||||
{
|
{
|
||||||
int AreaManager::get(entity::Character& character)
|
int AreaManager::get(entity::Character& character)
|
||||||
{
|
{
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "../../entity/character.hpp"
|
#include "../../entity/character.hpp"
|
||||||
|
|
||||||
namespace game::state::main
|
namespace game::state::play
|
||||||
{
|
{
|
||||||
class AreaManager
|
class AreaManager
|
||||||
{
|
{
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
using namespace game::resource::xml;
|
using namespace game::resource::xml;
|
||||||
using namespace game::util;
|
using namespace game::util;
|
||||||
|
|
||||||
namespace game::state::main
|
namespace game::state::play
|
||||||
{
|
{
|
||||||
void CharacterManager::update(entity::Character& character, entity::Cursor& cursor, Text& text, Canvas& canvas)
|
void CharacterManager::update(entity::Character& character, entity::Cursor& cursor, Text& text, Canvas& canvas)
|
||||||
{
|
{
|
||||||
@@ -36,12 +36,19 @@ namespace game::state::main
|
|||||||
|
|
||||||
isInteractingPrevious = isInteracting;
|
isInteractingPrevious = isInteracting;
|
||||||
isHoveringPrevious = isHovering;
|
isHoveringPrevious = isHovering;
|
||||||
|
isHoldInteractingPrevious = isHoldInteracting;
|
||||||
isHovering = false;
|
isHovering = false;
|
||||||
|
if (!isInteracting) isHoldInteracting = false;
|
||||||
|
|
||||||
if (isJustStoppedInteracting)
|
if (isJustStoppedHoldInteracting)
|
||||||
|
{
|
||||||
|
cursor.queue_play({cursor.defaultAnimation});
|
||||||
|
if (character.queuedPlay.empty()) character.queue_idle_animation();
|
||||||
|
isJustStoppedHoldInteracting = false;
|
||||||
|
}
|
||||||
|
else if (isJustStoppedInteracting)
|
||||||
{
|
{
|
||||||
cursor.queue_play({cursor.defaultAnimation});
|
cursor.queue_play({cursor.defaultAnimation});
|
||||||
if (cursor.mode == RUB) character.queue_idle_animation();
|
|
||||||
isJustStoppedInteracting = false;
|
isJustStoppedInteracting = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,7 +65,7 @@ namespace game::state::main
|
|||||||
auto rect = character.null_frame_rect(interactArea.nullID);
|
auto rect = character.null_frame_rect(interactArea.nullID);
|
||||||
|
|
||||||
if (cursor.state == entity::Cursor::DEFAULT && math::is_point_in_rectf(rect, cursorWorldPosition) &&
|
if (cursor.state == entity::Cursor::DEFAULT && math::is_point_in_rectf(rect, cursorWorldPosition) &&
|
||||||
!isImguiCaptureMouse && interactArea.type == cursor.mode)
|
!isImguiCaptureMouse && interactArea.typeID == cursor.interactTypeID)
|
||||||
{
|
{
|
||||||
cursor.state = entity::Cursor::HOVER;
|
cursor.state = entity::Cursor::HOVER;
|
||||||
cursor.queue_play({interactArea.animationCursorHover});
|
cursor.queue_play({interactArea.animationCursorHover});
|
||||||
@@ -68,8 +75,8 @@ namespace game::state::main
|
|||||||
if (isMouseLeftClick)
|
if (isMouseLeftClick)
|
||||||
{
|
{
|
||||||
isInteracting = true;
|
isInteracting = true;
|
||||||
|
isHoldInteracting = interactArea.isHold;
|
||||||
interactArea.sound.play();
|
interactArea.sound.play();
|
||||||
lastInteractType = cursor.mode;
|
|
||||||
|
|
||||||
if (interactArea.digestionBonusClick > 0 && character.calories > 0 && !character.isDigesting)
|
if (interactArea.digestionBonusClick > 0 && character.calories > 0 && !character.isDigesting)
|
||||||
character.digestionProgress += interactArea.digestionBonusClick;
|
character.digestionProgress += interactArea.digestionBonusClick;
|
||||||
@@ -105,11 +112,13 @@ namespace game::state::main
|
|||||||
isImguiCaptureMouse)
|
isImguiCaptureMouse)
|
||||||
{
|
{
|
||||||
isInteracting = false;
|
isInteracting = false;
|
||||||
|
isHoldInteracting = false;
|
||||||
interactAreaID = -1;
|
interactAreaID = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isInteracting != isInteractingPrevious && !isInteracting) isJustStoppedInteracting = true;
|
if (isInteracting != isInteractingPrevious && !isInteracting) isJustStoppedInteracting = true;
|
||||||
|
if (isHoldInteracting != isHoldInteractingPrevious && !isHoldInteracting) isJustStoppedHoldInteracting = true;
|
||||||
if (isHovering != isHoveringPrevious && !isHovering) isJustStoppedHovering = true;
|
if (isHovering != isHoveringPrevious && !isHovering) isJustStoppedHovering = true;
|
||||||
|
|
||||||
cursorWorldPositionPrevious = cursorWorldPosition;
|
cursorWorldPositionPrevious = cursorWorldPosition;
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
#include "../../entity/cursor.hpp"
|
#include "../../entity/cursor.hpp"
|
||||||
#include "text.hpp"
|
#include "text.hpp"
|
||||||
|
|
||||||
namespace game::state::main
|
namespace game::state::play
|
||||||
{
|
{
|
||||||
class CharacterManager
|
class CharacterManager
|
||||||
{
|
{
|
||||||
@@ -15,8 +15,10 @@ namespace game::state::main
|
|||||||
bool isHoveringPrevious{};
|
bool isHoveringPrevious{};
|
||||||
bool isJustStoppedInteracting{};
|
bool isJustStoppedInteracting{};
|
||||||
bool isJustStoppedHovering{};
|
bool isJustStoppedHovering{};
|
||||||
|
bool isHoldInteracting{};
|
||||||
|
bool isHoldInteractingPrevious{};
|
||||||
|
bool isJustStoppedHoldInteracting{};
|
||||||
int interactAreaID{-1};
|
int interactAreaID{-1};
|
||||||
InteractType lastInteractType{(InteractType)-1};
|
|
||||||
|
|
||||||
glm::vec2 cursorWorldPositionPrevious{};
|
glm::vec2 cursorWorldPositionPrevious{};
|
||||||
std::string queuedAnimation{};
|
std::string queuedAnimation{};
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
using namespace game::resource;
|
using namespace game::resource;
|
||||||
using namespace game::util::imgui;
|
using namespace game::util::imgui;
|
||||||
|
|
||||||
namespace game::state::main
|
namespace game::state::play
|
||||||
{
|
{
|
||||||
void Chat::update(Resources&, Text& text, entity::Character& character)
|
void Chat::update(Resources&, Text& text, entity::Character& character)
|
||||||
{
|
{
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
|
|
||||||
namespace game::state::main
|
namespace game::state::play
|
||||||
{
|
{
|
||||||
class Chat
|
class Chat
|
||||||
{
|
{
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
using namespace game::util::imgui;
|
using namespace game::util::imgui;
|
||||||
using namespace game::util;
|
using namespace game::util;
|
||||||
|
|
||||||
namespace game::state::main
|
namespace game::state::play
|
||||||
{
|
{
|
||||||
void Cheats::update(Resources&, entity::Character& character, Inventory& inventory, Text& text)
|
void Cheats::update(Resources&, entity::Character& character, Inventory& inventory, Text& text)
|
||||||
{
|
{
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
|
|
||||||
namespace game::state::main
|
namespace game::state::play
|
||||||
{
|
{
|
||||||
class Cheats
|
class Cheats
|
||||||
{
|
{
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
using namespace game::util::imgui;
|
using namespace game::util::imgui;
|
||||||
|
|
||||||
namespace game::state::main
|
namespace game::state::play
|
||||||
{
|
{
|
||||||
void Debug::update(entity::Character& character, entity::Cursor& cursor, ItemManager& itemManager, Canvas& canvas)
|
void Debug::update(entity::Character& character, entity::Cursor& cursor, ItemManager& itemManager, Canvas& canvas)
|
||||||
{
|
{
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
|
|
||||||
namespace game::state::main
|
namespace game::state::play
|
||||||
{
|
{
|
||||||
class Debug
|
class Debug
|
||||||
{
|
{
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
using namespace game::resource;
|
using namespace game::resource;
|
||||||
using namespace game::util;
|
using namespace game::util;
|
||||||
|
|
||||||
namespace game::state::main
|
namespace game::state::play
|
||||||
{
|
{
|
||||||
void Info::update(Resources& resources, entity::Character& character)
|
void Info::update(Resources& resources, entity::Character& character)
|
||||||
{
|
{
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
|
|
||||||
namespace game::state::main
|
namespace game::state::play
|
||||||
{
|
{
|
||||||
class Info
|
class Info
|
||||||
{
|
{
|
||||||
348
src/state/play/inventory.cpp
Normal file
348
src/state/play/inventory.cpp
Normal file
@@ -0,0 +1,348 @@
|
|||||||
|
#include "inventory.hpp"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
#include <format>
|
||||||
|
#include <ranges>
|
||||||
|
#include <tuple>
|
||||||
|
|
||||||
|
#include "../../util/color.hpp"
|
||||||
|
#include "../../util/imgui.hpp"
|
||||||
|
#include "../../util/imgui/widget.hpp"
|
||||||
|
#include "../../util/math.hpp"
|
||||||
|
|
||||||
|
using namespace game::util;
|
||||||
|
using namespace game::util::imgui;
|
||||||
|
using namespace game::entity;
|
||||||
|
using namespace game::resource;
|
||||||
|
using namespace glm;
|
||||||
|
|
||||||
|
namespace game::state::play
|
||||||
|
{
|
||||||
|
void Inventory::tick()
|
||||||
|
{
|
||||||
|
for (auto& [i, actor] : actors)
|
||||||
|
actor.tick();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Inventory::update(Resources& resources, ItemManager& itemManager, entity::Character& character)
|
||||||
|
{
|
||||||
|
static constexpr auto INFO_CHILD_HEIGHT_MULTIPLIER = 1.0f / 3.0f;
|
||||||
|
|
||||||
|
auto& schema = character.data.itemSchema;
|
||||||
|
|
||||||
|
auto quantity_get = [&](int itemID) -> int&
|
||||||
|
{
|
||||||
|
auto& quantity = values[itemID];
|
||||||
|
quantity = glm::clamp(0, quantity, schema.quantityMax);
|
||||||
|
return quantity;
|
||||||
|
};
|
||||||
|
|
||||||
|
auto is_possible_to_upgrade_get = [&](const resource::xml::Item::Entry& item)
|
||||||
|
{
|
||||||
|
return item.upgradeID.has_value() && item.upgradeCount.has_value() &&
|
||||||
|
schema.idToStringMap.contains(*item.upgradeID);
|
||||||
|
};
|
||||||
|
|
||||||
|
auto is_able_to_upgrade_get = [&](const resource::xml::Item::Entry& item, int quantity)
|
||||||
|
{ return is_possible_to_upgrade_get(item) && quantity >= *item.upgradeCount; };
|
||||||
|
|
||||||
|
auto item_use = [&](int itemID)
|
||||||
|
{
|
||||||
|
auto& item = schema.items[itemID];
|
||||||
|
auto& category = schema.categories[item.categoryID];
|
||||||
|
auto& quantity = quantity_get(itemID);
|
||||||
|
|
||||||
|
if (quantity <= 0) return;
|
||||||
|
|
||||||
|
if (category.isEdible)
|
||||||
|
{
|
||||||
|
if (itemManager.items.size() + 1 >= ItemManager::LIMIT)
|
||||||
|
character.data.itemSchema.sounds.dispose.play();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
character.data.itemSchema.sounds.summon.play();
|
||||||
|
itemManager.queuedItemIDs.emplace_back(itemID);
|
||||||
|
quantity--;
|
||||||
|
if (quantity <= 0) selectedItemID = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (item.isToggleSpritesheet)
|
||||||
|
{
|
||||||
|
character.spritesheet_set(character.spritesheetType == Character::NORMAL ? Character::ALTERNATE
|
||||||
|
: Character::NORMAL);
|
||||||
|
character.data.alternateSpritesheet.sound.play();
|
||||||
|
quantity--;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
auto item_upgrade = [&](int itemID, bool isAll)
|
||||||
|
{
|
||||||
|
auto& item = schema.items[itemID];
|
||||||
|
auto& quantity = quantity_get(itemID);
|
||||||
|
|
||||||
|
if (!is_possible_to_upgrade_get(item))
|
||||||
|
{
|
||||||
|
schema.sounds.upgradeFail.play();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_able_to_upgrade_get(item, quantity))
|
||||||
|
{
|
||||||
|
schema.sounds.upgradeFail.play();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isAll)
|
||||||
|
{
|
||||||
|
while (quantity >= *item.upgradeCount)
|
||||||
|
{
|
||||||
|
values.at(*item.upgradeID)++;
|
||||||
|
quantity -= *item.upgradeCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
values.at(*item.upgradeID)++;
|
||||||
|
quantity -= *item.upgradeCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
schema.sounds.upgrade.play();
|
||||||
|
|
||||||
|
if (quantity < *item.upgradeCount && selectedItemID == itemID) selectedItemID = *item.upgradeID;
|
||||||
|
};
|
||||||
|
|
||||||
|
auto item_canvas_get = [&](int itemID, ImVec2 size)
|
||||||
|
{
|
||||||
|
if (!actors.contains(itemID))
|
||||||
|
{
|
||||||
|
actors[itemID] = Actor(schema.anm2s[itemID], {}, Actor::SET);
|
||||||
|
rects[itemID] = actors[itemID].rect();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto& rect = rects[itemID];
|
||||||
|
auto rectSize = vec2(rect.z, rect.w);
|
||||||
|
auto previewScale = (size.x <= 0.0f || size.y <= 0.0f || rectSize.x <= 0.0f || rectSize.y <= 0.0f ||
|
||||||
|
!std::isfinite(rectSize.x) || !std::isfinite(rectSize.y))
|
||||||
|
? 0.0f
|
||||||
|
: std::min(size.x / rectSize.x, size.y / rectSize.y);
|
||||||
|
|
||||||
|
auto previewSize = rectSize * previewScale;
|
||||||
|
auto canvasSize = ivec2(std::max(1.0f, previewSize.x), std::max(1.0f, previewSize.y));
|
||||||
|
if (!canvases.contains(itemID)) canvases.emplace(itemID, Canvas(canvasSize, Canvas::FLIP));
|
||||||
|
|
||||||
|
auto& canvas = canvases[itemID];
|
||||||
|
canvas.zoom = math::to_percent(previewScale);
|
||||||
|
canvas.pan = vec2(rect.x, rect.y);
|
||||||
|
canvas.bind();
|
||||||
|
canvas.size_set(canvasSize);
|
||||||
|
canvas.clear();
|
||||||
|
actors[itemID].render(resources.shaders[shader::TEXTURE], resources.shaders[shader::RECT], canvas);
|
||||||
|
canvas.unbind();
|
||||||
|
|
||||||
|
return std::tuple<Canvas&, glm::vec4&>(canvas, rect);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!itemManager.returnItemIDs.empty())
|
||||||
|
{
|
||||||
|
for (auto& id : itemManager.returnItemIDs)
|
||||||
|
values[id]++;
|
||||||
|
itemManager.returnItemIDs.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui::BeginChild("##Inventory Child", ImGui::GetContentRegionAvail(), ImGuiChildFlags_None,
|
||||||
|
ImGuiWindowFlags_NoScrollbar))
|
||||||
|
{
|
||||||
|
auto inventoryCount = count();
|
||||||
|
auto available = ImGui::GetContentRegionAvail();
|
||||||
|
auto isItemSelected = selectedItemID >= 0 && selectedItemID < (int)schema.items.size();
|
||||||
|
auto isInfoVisible = isItemSelected || inventoryCount == 0;
|
||||||
|
auto infoChildHeight =
|
||||||
|
isInfoVisible ? available.y * INFO_CHILD_HEIGHT_MULTIPLIER + ImGui::GetStyle().ItemSpacing.y * 2.0f : 0.0f;
|
||||||
|
auto inventoryChildHeight =
|
||||||
|
isInfoVisible ? available.y - infoChildHeight - ImGui::GetStyle().ItemSpacing.y : available.y;
|
||||||
|
auto childSize = ImVec2(available.x, inventoryChildHeight);
|
||||||
|
auto infoChildSize = ImVec2(available.x, infoChildHeight);
|
||||||
|
|
||||||
|
if (ImGui::BeginChild("##Inventory List Child", childSize))
|
||||||
|
{
|
||||||
|
auto cursorPos = ImGui::GetCursorPos();
|
||||||
|
auto cursorStartX = ImGui::GetCursorPosX();
|
||||||
|
bool isAnyInventoryItemHovered{};
|
||||||
|
|
||||||
|
auto size = ImVec2(SIZE, SIZE);
|
||||||
|
|
||||||
|
for (int i = 0; i < (int)schema.items.size(); i++)
|
||||||
|
{
|
||||||
|
auto& item = schema.items[i];
|
||||||
|
auto& quantity = quantity_get(i);
|
||||||
|
auto& rarity = schema.rarities[item.rarityID];
|
||||||
|
|
||||||
|
if (rarity.isHidden && quantity <= 0) continue;
|
||||||
|
|
||||||
|
ImGui::PushID(i);
|
||||||
|
|
||||||
|
ImGui::SetCursorPos(cursorPos);
|
||||||
|
auto cursorScreenPos = ImGui::GetCursorScreenPos();
|
||||||
|
auto [canvas, rect] = item_canvas_get(i, size);
|
||||||
|
auto isSelected = selectedItemID == i;
|
||||||
|
|
||||||
|
if (isSelected)
|
||||||
|
{
|
||||||
|
auto selectedColor = ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered);
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_Button, selectedColor);
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, selectedColor);
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_ButtonActive, selectedColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto isPressed =
|
||||||
|
WIDGET_FX(ImGui::ImageButton("##Image Button", canvas.texture, size, ImVec2(), ImVec2(1, 1), ImVec4(),
|
||||||
|
quantity <= 0 ? ImVec4(0, 0, 0, 0.5f) : ImVec4(1, 1, 1, 1)));
|
||||||
|
if (isSelected) ImGui::PopStyleColor(3);
|
||||||
|
isAnyInventoryItemHovered = isAnyInventoryItemHovered || ImGui::IsItemHovered();
|
||||||
|
if (isPressed) selectedItemID = i;
|
||||||
|
if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left) && quantity > 0) item_use(i);
|
||||||
|
|
||||||
|
ImGui::PushFont(ImGui::GetFont(), Font::BIG);
|
||||||
|
|
||||||
|
auto text = std::format("x{}", quantity);
|
||||||
|
auto textPos = ImVec2(cursorScreenPos.x + size.x - ImGui::CalcTextSize(text.c_str()).x,
|
||||||
|
cursorScreenPos.y + size.y - ImGui::GetTextLineHeightWithSpacing());
|
||||||
|
ImGui::GetWindowDrawList()->AddText(textPos, ImGui::GetColorU32(ImGui::GetStyleColorVec4(ImGuiCol_Text)),
|
||||||
|
text.c_str());
|
||||||
|
ImGui::PopFont();
|
||||||
|
|
||||||
|
auto increment = ImGui::GetItemRectSize().x + ImGui::GetStyle().ItemSpacing.x;
|
||||||
|
cursorPos.x += increment;
|
||||||
|
|
||||||
|
if (cursorPos.x + increment > ImGui::GetContentRegionAvail().x)
|
||||||
|
{
|
||||||
|
cursorPos.x = cursorStartX;
|
||||||
|
cursorPos.y += increment;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::PopID();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui::IsWindowHovered() && ImGui::IsMouseClicked(ImGuiMouseButton_Left) && !isAnyInventoryItemHovered)
|
||||||
|
selectedItemID = -1;
|
||||||
|
}
|
||||||
|
ImGui::EndChild();
|
||||||
|
|
||||||
|
isItemSelected = selectedItemID >= 0 && selectedItemID < (int)schema.items.size();
|
||||||
|
auto selectedQuantity = isItemSelected ? quantity_get(selectedItemID) : 0;
|
||||||
|
auto isSelectedItemKnown = isItemSelected && selectedQuantity > 0;
|
||||||
|
|
||||||
|
if (isInfoVisible &&
|
||||||
|
ImGui::BeginChild("##Info Child", infoChildSize, ImGuiChildFlags_None, ImGuiWindowFlags_NoScrollbar))
|
||||||
|
{
|
||||||
|
ImGui::Separator();
|
||||||
|
auto isButtonChildVisible = selectedQuantity > 0;
|
||||||
|
ImGui::PushFont(resources.font.get(), Font::BIG);
|
||||||
|
auto buttonRowHeight = ImGui::GetFrameHeight();
|
||||||
|
auto buttonChildHeight =
|
||||||
|
isButtonChildVisible ? buttonRowHeight * 2.0f + ImGui::GetStyle().ItemSpacing.y * 5.0f : 0.0f;
|
||||||
|
auto buttonChildSize = ImVec2(ImGui::GetContentRegionAvail().x, buttonChildHeight);
|
||||||
|
auto infoBodySize =
|
||||||
|
ImVec2(ImGui::GetContentRegionAvail().x,
|
||||||
|
ImGui::GetContentRegionAvail().y - buttonChildSize.y -
|
||||||
|
(isButtonChildVisible ? ImGui::GetStyle().ItemSpacing.y : 0.0f));
|
||||||
|
ImGui::PopFont();
|
||||||
|
|
||||||
|
if (ImGui::BeginChild("##Info Content Child", infoBodySize))
|
||||||
|
{
|
||||||
|
if (!isItemSelected)
|
||||||
|
{
|
||||||
|
ImGui::PushFont(ImGui::GetFont(), Font::BIG);
|
||||||
|
ImGui::TextWrapped("%s", "Check the \"Arcade\" tab to earn rewards!");
|
||||||
|
ImGui::PopFont();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto& item = schema.items[selectedItemID];
|
||||||
|
auto& category = schema.categories[item.categoryID];
|
||||||
|
auto& rarity = schema.rarities[item.rarityID];
|
||||||
|
|
||||||
|
if (isSelectedItemKnown)
|
||||||
|
{
|
||||||
|
ImGui::PushFont(ImGui::GetFont(), Font::BIG);
|
||||||
|
ImGui::TextWrapped("%s (x%i)", item.name.c_str(), selectedQuantity);
|
||||||
|
ImGui::PopFont();
|
||||||
|
|
||||||
|
ImGui::Separator();
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_Text, ImGui::GetColorU32(imgui::to_imvec4(color::GRAY)));
|
||||||
|
ImGui::TextWrapped("-- %s (%s) --", category.name.c_str(), rarity.name.c_str());
|
||||||
|
if (item.flavorID.has_value())
|
||||||
|
ImGui::TextWrapped("Flavor: %s", schema.flavors[*item.flavorID].name.c_str());
|
||||||
|
if (item.calories.has_value()) ImGui::TextWrapped("%0.0f kcal", *item.calories);
|
||||||
|
if (item.digestionBonus.has_value())
|
||||||
|
{
|
||||||
|
if (*item.digestionBonus > 0)
|
||||||
|
ImGui::TextWrapped("Digestion Rate Bonus: +%0.2f%% / sec", *item.digestionBonus * 60.0f);
|
||||||
|
else if (*item.digestionBonus < 0)
|
||||||
|
ImGui::TextWrapped("Digestion Rate Penalty: %0.2f%% / sec", *item.digestionBonus * 60.0f);
|
||||||
|
}
|
||||||
|
if (item.eatSpeedBonus.has_value())
|
||||||
|
{
|
||||||
|
if (*item.eatSpeedBonus > 0)
|
||||||
|
ImGui::TextWrapped("Eat Speed Bonus: +%0.2f%% / sec", *item.eatSpeedBonus);
|
||||||
|
else if (*item.eatSpeedBonus < 0)
|
||||||
|
ImGui::TextWrapped("Eat Speed Penalty: %0.2f%% / sec", *item.eatSpeedBonus);
|
||||||
|
}
|
||||||
|
if (is_possible_to_upgrade_get(item))
|
||||||
|
ImGui::TextWrapped("Upgrade: %ix -> %s", *item.upgradeCount,
|
||||||
|
schema.idToStringMap.at(*item.upgradeID).c_str());
|
||||||
|
ImGui::PopStyleColor();
|
||||||
|
|
||||||
|
ImGui::Separator();
|
||||||
|
ImGui::TextWrapped("%s", item.description.c_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ImGui::PushFont(ImGui::GetFont(), Font::BIG);
|
||||||
|
ImGui::TextWrapped("%s", "???");
|
||||||
|
ImGui::PopFont();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImGui::EndChild();
|
||||||
|
|
||||||
|
if (isButtonChildVisible &&
|
||||||
|
ImGui::BeginChild("##Info Actions Child", buttonChildSize, ImGuiChildFlags_None,
|
||||||
|
ImGuiWindowFlags_NoScrollbar))
|
||||||
|
{
|
||||||
|
auto canUseSelectedItem = true;
|
||||||
|
auto canUpgradeSelectedItem = is_able_to_upgrade_get(schema.items[selectedItemID], selectedQuantity);
|
||||||
|
auto rowTwoButtonSize = row_widget_size_get(2);
|
||||||
|
|
||||||
|
ImGui::Separator();
|
||||||
|
ImGui::Dummy(ImVec2(0, ImGui::GetStyle().ItemSpacing.y));
|
||||||
|
|
||||||
|
ImGui::PushFont(ImGui::GetFont(), Font::BIG);
|
||||||
|
|
||||||
|
ImGui::BeginDisabled(!canUseSelectedItem);
|
||||||
|
if (WIDGET_FX(ImGui::Button("Spawn", {ImGui::GetContentRegionAvail().x, 0}))) item_use(selectedItemID);
|
||||||
|
ImGui::EndDisabled();
|
||||||
|
|
||||||
|
ImGui::BeginDisabled(!canUpgradeSelectedItem);
|
||||||
|
if (WIDGET_FX(ImGui::Button("Upgrade", rowTwoButtonSize))) item_upgrade(selectedItemID, false);
|
||||||
|
ImGui::SameLine();
|
||||||
|
if (WIDGET_FX(ImGui::Button("Upgrade All", rowTwoButtonSize))) item_upgrade(selectedItemID, true);
|
||||||
|
ImGui::EndDisabled();
|
||||||
|
|
||||||
|
ImGui::PopFont();
|
||||||
|
}
|
||||||
|
if (isButtonChildVisible) ImGui::EndChild();
|
||||||
|
}
|
||||||
|
if (isInfoVisible) ImGui::EndChild();
|
||||||
|
}
|
||||||
|
ImGui::EndChild();
|
||||||
|
}
|
||||||
|
|
||||||
|
int Inventory::count()
|
||||||
|
{
|
||||||
|
int count{};
|
||||||
|
for (auto& [type, quantity] : values)
|
||||||
|
count += quantity;
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
|
|
||||||
namespace game::state::main
|
namespace game::state::play
|
||||||
{
|
{
|
||||||
class Inventory
|
class Inventory
|
||||||
{
|
{
|
||||||
@@ -19,6 +19,7 @@ namespace game::state::main
|
|||||||
std::unordered_map<int, entity::Actor> actors{};
|
std::unordered_map<int, entity::Actor> actors{};
|
||||||
std::unordered_map<int, glm::vec4> rects{};
|
std::unordered_map<int, glm::vec4> rects{};
|
||||||
std::unordered_map<int, Canvas> canvases{};
|
std::unordered_map<int, Canvas> canvases{};
|
||||||
|
int selectedItemID{-1};
|
||||||
|
|
||||||
void tick();
|
void tick();
|
||||||
void update(Resources&, ItemManager&, entity::Character&);
|
void update(Resources&, ItemManager&, entity::Character&);
|
||||||
@@ -13,7 +13,7 @@ using namespace game::resource;
|
|||||||
using namespace game::util;
|
using namespace game::util;
|
||||||
using namespace glm;
|
using namespace glm;
|
||||||
|
|
||||||
namespace game::state::main
|
namespace game::state::play
|
||||||
{
|
{
|
||||||
void ItemManager::update(entity::Character& character, entity::Cursor& cursor, AreaManager& areaManager, Text& text,
|
void ItemManager::update(entity::Character& character, entity::Cursor& cursor, AreaManager& areaManager, Text& text,
|
||||||
const glm::vec4& bounds, Canvas& canvas)
|
const glm::vec4& bounds, Canvas& canvas)
|
||||||
@@ -54,7 +54,7 @@ namespace game::state::main
|
|||||||
if (isJustItemHeldStopped || isJustItemThrown)
|
if (isJustItemHeldStopped || isJustItemThrown)
|
||||||
{
|
{
|
||||||
cursor.queue_default_animation();
|
cursor.queue_default_animation();
|
||||||
if (!isJustItemThrown) character.queue_idle_animation();
|
if (!isJustItemThrown && character.queuedPlay.empty()) character.queue_idle_animation();
|
||||||
isJustItemHeldStopped = false;
|
isJustItemHeldStopped = false;
|
||||||
isJustItemThrown = false;
|
isJustItemThrown = false;
|
||||||
}
|
}
|
||||||
@@ -74,7 +74,11 @@ namespace game::state::main
|
|||||||
}
|
}
|
||||||
queuedItemIDs.clear();
|
queuedItemIDs.clear();
|
||||||
|
|
||||||
if (isMouseRightDown) cursor.queue_play({cursorSchema.animations.return_.get()});
|
if (isMouseRightDown)
|
||||||
|
{
|
||||||
|
auto animation = cursorSchema.animations.return_.get();
|
||||||
|
if (animation) cursor.queue_play({*animation});
|
||||||
|
}
|
||||||
|
|
||||||
if (auto heldItem = vector::find(items, heldItemIndex))
|
if (auto heldItem = vector::find(items, heldItemIndex))
|
||||||
{
|
{
|
||||||
@@ -173,7 +177,7 @@ namespace game::state::main
|
|||||||
|
|
||||||
// Food stolen
|
// Food stolen
|
||||||
if (auto animation = character.animation_get(character.animation_name_convert(eatArea.animation));
|
if (auto animation = character.animation_get(character.animation_name_convert(eatArea.animation));
|
||||||
character.is_playing(animation->name) && !isOverCapacity)
|
character.is_playing(animation->name))
|
||||||
{
|
{
|
||||||
if (!math::is_point_in_rectf(rect, heldItem->position))
|
if (!math::is_point_in_rectf(rect, heldItem->position))
|
||||||
text.set(dialogue.get(isOverCapacity ? dialogue.foodTakenFull : dialogue.foodTaken), character);
|
text.set(dialogue.get(isOverCapacity ? dialogue.foodTakenFull : dialogue.foodTaken), character);
|
||||||
@@ -208,7 +212,7 @@ namespace game::state::main
|
|||||||
if (math::is_point_in_rectf(item.rect(), cursorPosition) && !isImguiCaptureMouse)
|
if (math::is_point_in_rectf(item.rect(), cursorPosition) && !isImguiCaptureMouse)
|
||||||
{
|
{
|
||||||
isItemHovered = true;
|
isItemHovered = true;
|
||||||
cursor.queue_play({cursorSchema.animations.hover.get()});
|
if (auto animation = cursorSchema.animations.hover.get()) cursor.queue_play({*animation});
|
||||||
cursor.state = entity::Cursor::HOVER;
|
cursor.state = entity::Cursor::HOVER;
|
||||||
|
|
||||||
if (isMouseLeftClicked)
|
if (isMouseLeftClicked)
|
||||||
@@ -220,7 +224,7 @@ namespace game::state::main
|
|||||||
if (isMouseLeftDown)
|
if (isMouseLeftDown)
|
||||||
{
|
{
|
||||||
isItemHeld = true;
|
isItemHeld = true;
|
||||||
cursor.queue_play({cursorSchema.animations.grab.get()});
|
if (auto animation = cursorSchema.animations.grab.get()) cursor.queue_play({*animation});
|
||||||
cursor.state = entity::Cursor::ACTION;
|
cursor.state = entity::Cursor::ACTION;
|
||||||
heldItemIndex = i;
|
heldItemIndex = i;
|
||||||
heldItemMoveIndex = i;
|
heldItemMoveIndex = i;
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
#include "area_manager.hpp"
|
#include "area_manager.hpp"
|
||||||
#include "text.hpp"
|
#include "text.hpp"
|
||||||
|
|
||||||
namespace game::state::main
|
namespace game::state::play
|
||||||
{
|
{
|
||||||
class ItemManager
|
class ItemManager
|
||||||
{
|
{
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "menu.hpp"
|
#include "menu.hpp"
|
||||||
|
|
||||||
#include "../../util/imgui.hpp"
|
#include "../../util/imgui.hpp"
|
||||||
|
#include "../../util/imgui/style.hpp"
|
||||||
#include "../../util/imgui/widget.hpp"
|
#include "../../util/imgui/widget.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@@ -8,12 +9,17 @@
|
|||||||
using namespace game::util;
|
using namespace game::util;
|
||||||
using namespace game::util::imgui;
|
using namespace game::util::imgui;
|
||||||
|
|
||||||
namespace game::state::main
|
namespace game::state::play
|
||||||
{
|
{
|
||||||
void Menu::tick()
|
void Menu::tick()
|
||||||
{
|
{
|
||||||
inventory.tick();
|
inventory.tick();
|
||||||
play.tick();
|
skillCheck.tick();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Menu::color_set_check(Resources& resources, entity::Character& character)
|
||||||
|
{
|
||||||
|
imgui::style::color_set(resources.settings.isUseCharacterColor ? character.data.color : resources.settings.color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::update(Resources& resources, ItemManager& itemManager, entity::Character& character,
|
void Menu::update(Resources& resources, ItemManager& itemManager, entity::Character& character,
|
||||||
@@ -61,13 +67,13 @@ namespace game::state::main
|
|||||||
ImGui::EndTabItem();
|
ImGui::EndTabItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WIDGET_FX(ImGui::BeginTabItem("Play")))
|
if (WIDGET_FX(ImGui::BeginTabItem("Arcade")))
|
||||||
{
|
{
|
||||||
play.update(resources, character, inventory, text);
|
skillCheck.update(resources, character, inventory, text);
|
||||||
ImGui::EndTabItem();
|
ImGui::EndTabItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WIDGET_FX(ImGui::BeginTabItem("Items")))
|
if (WIDGET_FX(ImGui::BeginTabItem("Inventory")))
|
||||||
{
|
{
|
||||||
inventory.update(resources, itemManager, character);
|
inventory.update(resources, itemManager, character);
|
||||||
ImGui::EndTabItem();
|
ImGui::EndTabItem();
|
||||||
@@ -75,13 +81,14 @@ namespace game::state::main
|
|||||||
|
|
||||||
if (WIDGET_FX(ImGui::BeginTabItem("Stats")))
|
if (WIDGET_FX(ImGui::BeginTabItem("Stats")))
|
||||||
{
|
{
|
||||||
stats.update(resources, play, character);
|
stats.update(resources, skillCheck, character);
|
||||||
ImGui::EndTabItem();
|
ImGui::EndTabItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WIDGET_FX(ImGui::BeginTabItem("Settings")))
|
if (WIDGET_FX(ImGui::BeginTabItem("Settings")))
|
||||||
{
|
{
|
||||||
configuration.update(resources, Configuration::MAIN);
|
settingsMenu.update(resources, SettingsMenu::PLAY);
|
||||||
|
if (settingsMenu.isJustColorSet) color_set_check(resources, character);
|
||||||
ImGui::EndTabItem();
|
ImGui::EndTabItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,11 +98,13 @@ namespace game::state::main
|
|||||||
ImGui::EndTabItem();
|
ImGui::EndTabItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isDebug && WIDGET_FX(ImGui::BeginTabItem("Debug")))
|
#if DEBUG
|
||||||
|
if (WIDGET_FX(ImGui::BeginTabItem("Debug")))
|
||||||
{
|
{
|
||||||
debug.update(character, cursor, itemManager, canvas);
|
debug.update(character, cursor, itemManager, canvas);
|
||||||
ImGui::EndTabItem();
|
ImGui::EndTabItem();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
ImGui::EndTabBar();
|
ImGui::EndTabBar();
|
||||||
}
|
}
|
||||||
@@ -2,37 +2,35 @@
|
|||||||
|
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
|
|
||||||
#include "../configuration.hpp"
|
#include "../settings_menu.hpp"
|
||||||
|
|
||||||
|
#include "arcade/skill_check.hpp"
|
||||||
#include "chat.hpp"
|
#include "chat.hpp"
|
||||||
#include "cheats.hpp"
|
#include "cheats.hpp"
|
||||||
#include "debug.hpp"
|
#include "debug.hpp"
|
||||||
#include "play.hpp"
|
|
||||||
#include "stats.hpp"
|
#include "stats.hpp"
|
||||||
#include "text.hpp"
|
#include "text.hpp"
|
||||||
|
|
||||||
#include "../../util/imgui/window_slide.hpp"
|
#include "../../util/imgui/window_slide.hpp"
|
||||||
|
|
||||||
namespace game::state::main
|
namespace game::state::play
|
||||||
{
|
{
|
||||||
class Menu
|
class Menu
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Play play;
|
SkillCheck skillCheck;
|
||||||
Chat chat;
|
Chat chat;
|
||||||
Cheats cheats;
|
Cheats cheats;
|
||||||
Debug debug;
|
Debug debug;
|
||||||
Stats stats;
|
Stats stats;
|
||||||
Inventory inventory;
|
Inventory inventory;
|
||||||
|
|
||||||
state::Configuration configuration;
|
state::SettingsMenu settingsMenu;
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
bool isCheats{true};
|
bool isCheats{true};
|
||||||
bool isDebug{true};
|
#elif
|
||||||
#else
|
|
||||||
bool isCheats{};
|
bool isCheats{};
|
||||||
bool isDebug{};
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool isOpen{true};
|
bool isOpen{true};
|
||||||
@@ -41,5 +39,6 @@ namespace game::state::main
|
|||||||
|
|
||||||
void tick();
|
void tick();
|
||||||
void update(Resources&, ItemManager&, entity::Character&, entity::Cursor&, Text&, Canvas&);
|
void update(Resources&, ItemManager&, entity::Character&, entity::Cursor&, Text&, Canvas&);
|
||||||
|
void color_set_check(Resources&, entity::Character&);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -7,9 +7,9 @@
|
|||||||
using namespace game::resource;
|
using namespace game::resource;
|
||||||
using namespace game::util;
|
using namespace game::util;
|
||||||
|
|
||||||
namespace game::state::main
|
namespace game::state::play
|
||||||
{
|
{
|
||||||
void Stats::update(Resources& resources, Play& play, entity::Character& character)
|
void Stats::update(Resources& resources, SkillCheck& skillCheck, entity::Character& character)
|
||||||
{
|
{
|
||||||
ImGui::PushFont(ImGui::GetFont(), Font::BIG);
|
ImGui::PushFont(ImGui::GetFont(), Font::BIG);
|
||||||
ImGui::TextUnformatted(character.data.name.c_str());
|
ImGui::TextUnformatted(character.data.name.c_str());
|
||||||
@@ -17,7 +17,7 @@ namespace game::state::main
|
|||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
auto& playSchema = character.data.playSchema;
|
auto& skillCheckSchema = character.data.skillCheckSchema;
|
||||||
auto& system = resources.settings.measurementSystem;
|
auto& system = resources.settings.measurementSystem;
|
||||||
auto weight = character.weight_get(system);
|
auto weight = character.weight_get(system);
|
||||||
auto weightUnit = system == measurement::IMPERIAL ? "lbs" : "kg";
|
auto weightUnit = system == measurement::IMPERIAL ? "lbs" : "kg";
|
||||||
@@ -32,17 +32,17 @@ namespace game::state::main
|
|||||||
ImGui::Text("Total Calories Consumed: %0.0f kcal", character.totalCaloriesConsumed);
|
ImGui::Text("Total Calories Consumed: %0.0f kcal", character.totalCaloriesConsumed);
|
||||||
ImGui::Text("Total Food Items Eaten: %i", character.totalFoodItemsEaten);
|
ImGui::Text("Total Food Items Eaten: %i", character.totalFoodItemsEaten);
|
||||||
|
|
||||||
ImGui::SeparatorText("Play");
|
ImGui::SeparatorText("Skill Check");
|
||||||
|
|
||||||
ImGui::Text("Best: %i pts (%ix)", play.highScore, play.bestCombo);
|
ImGui::Text("Best: %i pts (%ix)", skillCheck.highScore, skillCheck.bestCombo);
|
||||||
ImGui::Text("Total Plays: %i", play.totalPlays);
|
ImGui::Text("Total Skill Checks: %i", skillCheck.totalPlays);
|
||||||
|
|
||||||
for (int i = 0; i < (int)playSchema.grades.size(); i++)
|
for (int i = 0; i < (int)skillCheckSchema.grades.size(); i++)
|
||||||
{
|
{
|
||||||
auto& grade = playSchema.grades[i];
|
auto& grade = skillCheckSchema.grades[i];
|
||||||
ImGui::Text("%s: %i", grade.namePlural.c_str(), play.gradeCounts[i]);
|
ImGui::Text("%s: %i", grade.namePlural.c_str(), skillCheck.gradeCounts[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::Text("Accuracy: %0.2f%%", play.accuracy_score_get(character));
|
ImGui::Text("Accuracy: %0.2f%%", skillCheck.accuracy_score_get(character));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,15 +3,15 @@
|
|||||||
#include "../../entity/character.hpp"
|
#include "../../entity/character.hpp"
|
||||||
#include "../../resources.hpp"
|
#include "../../resources.hpp"
|
||||||
|
|
||||||
#include "play.hpp"
|
#include "arcade/skill_check.hpp"
|
||||||
|
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
|
|
||||||
namespace game::state::main
|
namespace game::state::play
|
||||||
{
|
{
|
||||||
class Stats
|
class Stats
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void update(Resources&, Play&, entity::Character&);
|
void update(Resources&, SkillCheck&, entity::Character&);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
using namespace game::util;
|
using namespace game::util;
|
||||||
|
|
||||||
namespace game::state::main
|
namespace game::state::play
|
||||||
{
|
{
|
||||||
const char* utf8_advance_chars(const char* text, const char* end, int count)
|
const char* utf8_advance_chars(const char* text, const char* end, int count)
|
||||||
{
|
{
|
||||||
@@ -28,7 +28,7 @@ namespace game::state::main
|
|||||||
return it;
|
return it;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Text::set(resource::xml::Dialogue::Entry* dialogueEntry, entity::Character& character)
|
void Text::set(resource::xml::Dialogue::Entry* dialogueEntry, entity::Character& character, bool isInterruptible)
|
||||||
{
|
{
|
||||||
if (!dialogueEntry) return;
|
if (!dialogueEntry) return;
|
||||||
this->entry = dialogueEntry;
|
this->entry = dialogueEntry;
|
||||||
@@ -38,7 +38,8 @@ namespace game::state::main
|
|||||||
time = 0.0f;
|
time = 0.0f;
|
||||||
isEnabled = true;
|
isEnabled = true;
|
||||||
character.isTalking = true;
|
character.isTalking = true;
|
||||||
if (!dialogueEntry->animation.empty()) character.queue_play({dialogueEntry->animation});
|
if (!dialogueEntry->animation.empty())
|
||||||
|
character.queue_play({.animation = dialogueEntry->animation, .isInterruptible = isInterruptible});
|
||||||
if (dialogueEntry->text.empty()) isEnabled = false;
|
if (dialogueEntry->text.empty()) isEnabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
#include "../../resources.hpp"
|
#include "../../resources.hpp"
|
||||||
|
|
||||||
namespace game::state::main
|
namespace game::state::play
|
||||||
{
|
{
|
||||||
class Text
|
class Text
|
||||||
{
|
{
|
||||||
@@ -21,7 +21,7 @@ namespace game::state::main
|
|||||||
bool isEnabled{true};
|
bool isEnabled{true};
|
||||||
float time{};
|
float time{};
|
||||||
|
|
||||||
void set(resource::xml::Dialogue::Entry*, entity::Character&);
|
void set(resource::xml::Dialogue::Entry*, entity::Character&, bool isInterruptible = true);
|
||||||
void tick(entity::Character&);
|
void tick(entity::Character&);
|
||||||
void update(entity::Character&);
|
void update(entity::Character&);
|
||||||
bool is_interruptible() const;
|
bool is_interruptible() const;
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
#include <ranges>
|
#include <ranges>
|
||||||
|
|
||||||
namespace game::state::main
|
namespace game::state::play
|
||||||
{
|
{
|
||||||
void Toasts::tick()
|
void Toasts::tick()
|
||||||
{
|
{
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace game::state::main
|
namespace game::state::play
|
||||||
{
|
{
|
||||||
class Toasts
|
class Toasts
|
||||||
{
|
{
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
using namespace game::util;
|
using namespace game::util;
|
||||||
using namespace game::util::imgui;
|
using namespace game::util::imgui;
|
||||||
|
|
||||||
namespace game::state::main
|
namespace game::state::play
|
||||||
{
|
{
|
||||||
void Tools::update(entity::Character& character, entity::Cursor& cursor, World& world, World::Focus focus,
|
void Tools::update(entity::Character& character, entity::Cursor& cursor, World& world, World::Focus focus,
|
||||||
Canvas& canvas)
|
Canvas& canvas)
|
||||||
@@ -47,21 +47,20 @@ namespace game::state::main
|
|||||||
{
|
{
|
||||||
auto buttonSize = imgui::to_imvec2(vec2(ImGui::GetContentRegionAvail().x));
|
auto buttonSize = imgui::to_imvec2(vec2(ImGui::GetContentRegionAvail().x));
|
||||||
|
|
||||||
auto cursor_mode_button = [&](const char* name, InteractType mode)
|
auto cursor_mode_button = [&](const std::string& name, int interactTypeID)
|
||||||
{
|
{
|
||||||
auto isMode = cursor.mode == mode;
|
auto isMode = cursor.interactTypeID == interactTypeID;
|
||||||
ImGui::PushStyleColor(ImGuiCol_Button,
|
ImGui::PushStyleColor(ImGuiCol_Button,
|
||||||
ImGui::GetStyleColorVec4(isMode ? ImGuiCol_ButtonHovered : ImGuiCol_Button));
|
ImGui::GetStyleColorVec4(isMode ? ImGuiCol_ButtonHovered : ImGuiCol_Button));
|
||||||
if (WIDGET_FX(ImGui::Button(name, buttonSize))) cursor.mode = mode;
|
if (WIDGET_FX(ImGui::Button(name.c_str(), buttonSize))) cursor.interactTypeID = interactTypeID;
|
||||||
ImGui::PopStyleColor();
|
ImGui::PopStyleColor();
|
||||||
};
|
};
|
||||||
|
|
||||||
if (WIDGET_FX(ImGui::Button("Home", buttonSize))) world.character_focus(character, canvas, focus);
|
if (WIDGET_FX(ImGui::Button("Home", buttonSize))) world.character_focus(character, canvas, focus);
|
||||||
ImGui::SetItemTooltip("%s", "Reset camera view.\n(Shortcut: Home)");
|
ImGui::SetItemTooltip("%s", "Reset camera view.\n(Shortcut: Home)");
|
||||||
|
|
||||||
cursor_mode_button("Rub", InteractType::RUB);
|
for (int i = 0; i < (int)character.data.interactTypeNames.size(); i++)
|
||||||
cursor_mode_button("Kiss", InteractType::KISS);
|
cursor_mode_button(character.data.interactTypeNames[i], i);
|
||||||
cursor_mode_button("Smack", InteractType::SMACK);
|
|
||||||
}
|
}
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
#include "../../util/imgui/window_slide.hpp"
|
#include "../../util/imgui/window_slide.hpp"
|
||||||
#include "world.hpp"
|
#include "world.hpp"
|
||||||
|
|
||||||
namespace game::state::main
|
namespace game::state::play
|
||||||
{
|
{
|
||||||
class Tools
|
class Tools
|
||||||
{
|
{
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
using namespace game::util;
|
using namespace game::util;
|
||||||
|
|
||||||
namespace game::state::main
|
namespace game::state::play
|
||||||
{
|
{
|
||||||
void World::set(entity::Character& character, Canvas& canvas, Focus focus)
|
void World::set(entity::Character& character, Canvas& canvas, Focus focus)
|
||||||
{
|
{
|
||||||
@@ -22,15 +22,16 @@ namespace game::state::main
|
|||||||
auto& pan = canvas.pan;
|
auto& pan = canvas.pan;
|
||||||
auto& zoom = canvas.zoom;
|
auto& zoom = canvas.zoom;
|
||||||
auto& io = ImGui::GetIO();
|
auto& io = ImGui::GetIO();
|
||||||
bool isPan{true};
|
|
||||||
auto isMouseMiddleDown = ImGui::IsMouseDown(ImGuiMouseButton_Middle);
|
auto isMouseMiddleDown = ImGui::IsMouseDown(ImGuiMouseButton_Middle);
|
||||||
|
auto isMouseLeftDown = ImGui::IsMouseDown(ImGuiMouseButton_Left);
|
||||||
|
auto isCtrlDown = ImGui::IsKeyDown(ImGuiMod_Ctrl);
|
||||||
auto panMultiplier = ZOOM_BASE / zoom;
|
auto panMultiplier = ZOOM_BASE / zoom;
|
||||||
|
|
||||||
if (!ImGui::IsWindowHovered(ImGuiHoveredFlags_AnyWindow) && !ImGui::IsAnyItemActive())
|
if (!ImGui::IsWindowHovered(ImGuiHoveredFlags_AnyWindow) && !ImGui::IsAnyItemActive())
|
||||||
{
|
{
|
||||||
if ((isMouseMiddleDown) && isPan)
|
if ((isMouseMiddleDown) || (isMouseLeftDown && isCtrlDown))
|
||||||
{
|
{
|
||||||
cursor.queue_play({cursorSchema.animations.pan.get()});
|
if (auto animation = cursorSchema.animations.pan.get()) cursor.queue_play({*animation});
|
||||||
pan -= imgui::to_vec2(io.MouseDelta) * panMultiplier;
|
pan -= imgui::to_vec2(io.MouseDelta) * panMultiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,7 +44,7 @@ namespace game::state::main
|
|||||||
auto zoomFactorBefore = math::to_unit(zoomBefore);
|
auto zoomFactorBefore = math::to_unit(zoomBefore);
|
||||||
auto cursorWorld = pan + (cursorPos / zoomFactorBefore);
|
auto cursorWorld = pan + (cursorPos / zoomFactorBefore);
|
||||||
|
|
||||||
cursor.queue_play({cursorSchema.animations.zoom.get()});
|
if (auto animation = cursorSchema.animations.zoom.get()) cursor.queue_play({*animation});
|
||||||
|
|
||||||
zoom = glm::clamp(ZOOM_MIN, zoom + (io.MouseWheel * ZOOM_STEP), ZOOM_MAX);
|
zoom = glm::clamp(ZOOM_MIN, zoom + (io.MouseWheel * ZOOM_STEP), ZOOM_MAX);
|
||||||
|
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../../canvas.hpp"
|
#include "../../render/canvas.hpp"
|
||||||
#include "../../entity/character.hpp"
|
#include "../../entity/character.hpp"
|
||||||
|
|
||||||
#include "character_manager.hpp"
|
#include "character_manager.hpp"
|
||||||
#include "item_manager.hpp"
|
#include "item_manager.hpp"
|
||||||
|
|
||||||
namespace game::state::main
|
namespace game::state::play
|
||||||
{
|
{
|
||||||
class World
|
class World
|
||||||
{
|
{
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../canvas.hpp"
|
#include "../render/canvas.hpp"
|
||||||
|
|
||||||
#include "select/characters.hpp"
|
#include "select/characters.hpp"
|
||||||
#include "select/info.hpp"
|
#include "select/info.hpp"
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
#include "characters.hpp"
|
#include "characters.hpp"
|
||||||
|
|
||||||
#include <ranges>
|
#include "../../util/imgui/style.hpp"
|
||||||
|
|
||||||
#include "../../util/imgui/widget.hpp"
|
#include "../../util/imgui/widget.hpp"
|
||||||
|
|
||||||
using namespace game::util::imgui;
|
using namespace game::util;
|
||||||
|
|
||||||
namespace game::state::select
|
namespace game::state::select
|
||||||
{
|
{
|
||||||
@@ -39,6 +38,7 @@ namespace game::state::select
|
|||||||
ImGui::PushID(i);
|
ImGui::PushID(i);
|
||||||
|
|
||||||
ImGui::SetCursorPos(cursorPos);
|
ImGui::SetCursorPos(cursorPos);
|
||||||
|
imgui::style::color_set(character.color);
|
||||||
|
|
||||||
auto isSelected = i == characterIndex;
|
auto isSelected = i == characterIndex;
|
||||||
|
|
||||||
@@ -64,13 +64,14 @@ namespace game::state::select
|
|||||||
}
|
}
|
||||||
|
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
|
imgui::style::color_set(resources.settings.color);
|
||||||
}
|
}
|
||||||
ImGui::EndTabItem();
|
ImGui::EndTabItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WIDGET_FX(ImGui::BeginTabItem("Configuration")))
|
if (WIDGET_FX(ImGui::BeginTabItem("Settings")))
|
||||||
{
|
{
|
||||||
configuration.update(resources);
|
settingsMenu.update(resources);
|
||||||
ImGui::EndTabItem();
|
ImGui::EndTabItem();
|
||||||
}
|
}
|
||||||
ImGui::EndTabBar();
|
ImGui::EndTabBar();
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../../resources.hpp"
|
#include "../../resources.hpp"
|
||||||
#include "../configuration.hpp"
|
#include "../settings_menu.hpp"
|
||||||
|
|
||||||
namespace game::state::select
|
namespace game::state::select
|
||||||
{
|
{
|
||||||
class Characters
|
class Characters
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Configuration configuration;
|
SettingsMenu settingsMenu;
|
||||||
|
|
||||||
void update(Resources&, int& characterIndex);
|
void update(Resources&, int& characterIndex);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "../../util/color.hpp"
|
#include "../../util/color.hpp"
|
||||||
#include "../../util/imgui.hpp"
|
#include "../../util/imgui.hpp"
|
||||||
|
#include "../../util/imgui/style.hpp"
|
||||||
#include "../../util/imgui/widget.hpp"
|
#include "../../util/imgui/widget.hpp"
|
||||||
#include "../../util/vector.hpp"
|
#include "../../util/vector.hpp"
|
||||||
|
|
||||||
@@ -18,6 +19,7 @@ namespace game::state::select
|
|||||||
|
|
||||||
auto& style = ImGui::GetStyle();
|
auto& style = ImGui::GetStyle();
|
||||||
auto viewport = ImGui::GetMainViewport();
|
auto viewport = ImGui::GetMainViewport();
|
||||||
|
auto& character = resources.characterPreviews[characterIndex];
|
||||||
|
|
||||||
auto size = ImVec2(viewport->Size.x / 2.0f - (style.WindowPadding.x * 2.0f),
|
auto size = ImVec2(viewport->Size.x / 2.0f - (style.WindowPadding.x * 2.0f),
|
||||||
(viewport->Size.y / 2.0f) - (style.WindowPadding.y * 2.0f));
|
(viewport->Size.y / 2.0f) - (style.WindowPadding.y * 2.0f));
|
||||||
@@ -25,12 +27,12 @@ namespace game::state::select
|
|||||||
|
|
||||||
ImGui::SetNextWindowSize(size);
|
ImGui::SetNextWindowSize(size);
|
||||||
ImGui::SetNextWindowPos(pos);
|
ImGui::SetNextWindowPos(pos);
|
||||||
|
imgui::style::color_set(character.color);
|
||||||
|
|
||||||
if (ImGui::Begin("##Info", nullptr,
|
if (ImGui::Begin("##Info", nullptr,
|
||||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
||||||
ImGuiWindowFlags_NoTitleBar))
|
ImGuiWindowFlags_NoTitleBar))
|
||||||
{
|
{
|
||||||
auto& character = resources.characterPreviews[characterIndex];
|
|
||||||
auto& save = character.save;
|
auto& save = character.save;
|
||||||
auto& system = resources.settings.measurementSystem;
|
auto& system = resources.settings.measurementSystem;
|
||||||
auto& weight = save.is_valid() ? save.weight : character.weight;
|
auto& weight = save.is_valid() ? save.weight : character.weight;
|
||||||
@@ -123,5 +125,6 @@ namespace game::state::select
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
imgui::style::color_set(resources.settings.color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#include "../../util/imgui.hpp"
|
#include "../../util/imgui.hpp"
|
||||||
|
#include "../../util/imgui/style.hpp"
|
||||||
#include "../../util/imgui/widget.hpp"
|
#include "../../util/imgui/widget.hpp"
|
||||||
#include "../../util/vector.hpp"
|
#include "../../util/vector.hpp"
|
||||||
|
|
||||||
@@ -25,13 +26,14 @@ namespace game::state::select
|
|||||||
|
|
||||||
auto& style = ImGui::GetStyle();
|
auto& style = ImGui::GetStyle();
|
||||||
auto viewport = ImGui::GetMainViewport();
|
auto viewport = ImGui::GetMainViewport();
|
||||||
|
auto& character = resources.characterPreviews[characterIndex];
|
||||||
auto size = ImVec2(viewport->Size.x / 2.0f - (style.WindowPadding.x * 2.0f),
|
auto size = ImVec2(viewport->Size.x / 2.0f - (style.WindowPadding.x * 2.0f),
|
||||||
(viewport->Size.y / 2.0f) - (style.WindowPadding.y * 2.0f));
|
(viewport->Size.y / 2.0f) - (style.WindowPadding.y * 2.0f));
|
||||||
auto pos = ImVec2(style.WindowPadding.x, style.WindowPadding.y);
|
auto pos = ImVec2(style.WindowPadding.x, style.WindowPadding.y);
|
||||||
|
|
||||||
ImGui::SetNextWindowSize(size);
|
ImGui::SetNextWindowSize(size);
|
||||||
ImGui::SetNextWindowPos(pos);
|
ImGui::SetNextWindowPos(pos);
|
||||||
|
imgui::style::color_set(character.color);
|
||||||
|
|
||||||
if (ImGui::Begin("##Preview", nullptr,
|
if (ImGui::Begin("##Preview", nullptr,
|
||||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
||||||
@@ -39,8 +41,6 @@ namespace game::state::select
|
|||||||
{
|
{
|
||||||
if (ImGui::BeginTabBar("##Preview Tab Bar"))
|
if (ImGui::BeginTabBar("##Preview Tab Bar"))
|
||||||
{
|
{
|
||||||
auto& character = resources.characterPreviews[characterIndex];
|
|
||||||
|
|
||||||
auto available = ImGui::GetContentRegionAvail();
|
auto available = ImGui::GetContentRegionAvail();
|
||||||
auto availableSize = imgui::to_vec2(available);
|
auto availableSize = imgui::to_vec2(available);
|
||||||
auto textureSize = vec2(character.render.size);
|
auto textureSize = vec2(character.render.size);
|
||||||
@@ -106,5 +106,6 @@ namespace game::state::select
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
imgui::style::color_set(resources.settings.color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
#include "configuration.hpp"
|
#include "settings_menu.hpp"
|
||||||
|
|
||||||
#include <glm/gtc/type_ptr.hpp>
|
#include <glm/gtc/type_ptr.hpp>
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
|
|
||||||
#include "../util/math.hpp"
|
|
||||||
#include "../util/imgui/style.hpp"
|
#include "../util/imgui/style.hpp"
|
||||||
#include "../util/imgui/widget.hpp"
|
#include "../util/imgui/widget.hpp"
|
||||||
|
#include "../util/math.hpp"
|
||||||
#include "../util/measurement.hpp"
|
#include "../util/measurement.hpp"
|
||||||
|
|
||||||
using namespace game::util;
|
using namespace game::util;
|
||||||
@@ -13,13 +13,15 @@ using namespace game::util::imgui;
|
|||||||
|
|
||||||
namespace game::state
|
namespace game::state
|
||||||
{
|
{
|
||||||
void Configuration::update(Resources& resources, Mode mode)
|
void SettingsMenu::update(Resources& resources, Mode mode)
|
||||||
{
|
{
|
||||||
auto& settings = resources.settings;
|
auto& settings = resources.settings;
|
||||||
auto& measurementSystem = settings.measurementSystem;
|
auto& measurementSystem = settings.measurementSystem;
|
||||||
auto& volume = settings.volume;
|
auto& volume = settings.volume;
|
||||||
auto& color = settings.color;
|
auto& color = settings.color;
|
||||||
|
|
||||||
|
isJustColorSet = false;
|
||||||
|
|
||||||
ImGui::SeparatorText("Measurement System");
|
ImGui::SeparatorText("Measurement System");
|
||||||
WIDGET_FX(ImGui::RadioButton("Metric", (int*)&measurementSystem, measurement::METRIC));
|
WIDGET_FX(ImGui::RadioButton("Metric", (int*)&measurementSystem, measurement::METRIC));
|
||||||
ImGui::SetItemTooltip("%s", "Use kilograms (kg).");
|
ImGui::SetItemTooltip("%s", "Use kilograms (kg).");
|
||||||
@@ -34,15 +36,27 @@ namespace game::state
|
|||||||
|
|
||||||
ImGui::SeparatorText("Appearance");
|
ImGui::SeparatorText("Appearance");
|
||||||
|
|
||||||
|
if (WIDGET_FX(ImGui::Checkbox("Use Character Color", &settings.isUseCharacterColor))) isJustColorSet = true;
|
||||||
|
ImGui::SetItemTooltip("When playing, the UI will use the character's preset UI color.");
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::BeginDisabled(settings.isUseCharacterColor);
|
||||||
if (WIDGET_FX(
|
if (WIDGET_FX(
|
||||||
ImGui::ColorEdit3("Color", value_ptr(color), ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoTooltip)))
|
ImGui::ColorEdit3("Color", value_ptr(color), ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoTooltip)))
|
||||||
|
{
|
||||||
style::color_set(color);
|
style::color_set(color);
|
||||||
|
isJustColorSet = true;
|
||||||
|
}
|
||||||
ImGui::SetItemTooltip("%s", "Change the UI color.");
|
ImGui::SetItemTooltip("%s", "Change the UI color.");
|
||||||
|
ImGui::EndDisabled();
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
if (WIDGET_FX(ImGui::Button("Reset to Default", ImVec2(-FLT_MIN, 0)))) settings = resource::xml::Settings();
|
if (WIDGET_FX(ImGui::Button("Reset to Default", ImVec2(-FLT_MIN, 0))))
|
||||||
|
{
|
||||||
|
settings = resource::xml::Settings();
|
||||||
|
style::color_set(settings.color);
|
||||||
|
}
|
||||||
|
|
||||||
if (mode == MAIN)
|
if (mode == PLAY)
|
||||||
{
|
{
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
@@ -4,17 +4,18 @@
|
|||||||
|
|
||||||
namespace game::state
|
namespace game::state
|
||||||
{
|
{
|
||||||
class Configuration
|
class SettingsMenu
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum Mode
|
enum Mode
|
||||||
{
|
{
|
||||||
SELECT,
|
SELECT,
|
||||||
MAIN
|
PLAY
|
||||||
};
|
};
|
||||||
|
|
||||||
bool isGoToSelect{};
|
bool isGoToSelect{};
|
||||||
bool isSave{};
|
bool isSave{};
|
||||||
|
bool isJustColorSet{};
|
||||||
|
|
||||||
void update(Resources&, Mode = SELECT);
|
void update(Resources&, Mode = SELECT);
|
||||||
};
|
};
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
namespace game
|
|
||||||
{
|
|
||||||
#define LIST \
|
|
||||||
X(RUB, "Rub") \
|
|
||||||
X(KISS, "Kiss") \
|
|
||||||
X(SMACK, "Smack")
|
|
||||||
|
|
||||||
enum InteractType
|
|
||||||
{
|
|
||||||
#define X(symbol, string) symbol,
|
|
||||||
LIST
|
|
||||||
#undef X
|
|
||||||
};
|
|
||||||
|
|
||||||
static constexpr const char* INTERACT_TYPE_STRINGS[] = {
|
|
||||||
#define X(symbol, string) string,
|
|
||||||
LIST
|
|
||||||
#undef X
|
|
||||||
};
|
|
||||||
|
|
||||||
#undef LIST
|
|
||||||
}
|
|
||||||
@@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
#include "../log.hpp"
|
#include "../log.hpp"
|
||||||
|
|
||||||
|
#include <format>
|
||||||
|
|
||||||
namespace game::util::physfs
|
namespace game::util::physfs
|
||||||
{
|
{
|
||||||
std::string path_normalize(std::string_view path)
|
std::string path_normalize(std::string_view path)
|
||||||
|
|||||||
Reference in New Issue
Block a user