Merge branch 'master' of http://sig.projectdivar.com/sigonasr2/AdventuresInLestoria
commit
096acb2081
@ -0,0 +1,247 @@ |
||||
#pragma region License |
||||
/*
|
||||
License (OLC-3) |
||||
~~~~~~~~~~~~~~~ |
||||
|
||||
Copyright 2024 Joshua Sigona <sigonasr2@gmail.com> |
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, |
||||
are permitted provided that the following conditions are met: |
||||
|
||||
1. Redistributions or derivations of source code must retain the above copyright |
||||
notice, this list of conditions and the following disclaimer. |
||||
|
||||
2. Redistributions or derivative works in binary form must reproduce the above |
||||
copyright notice. This list of conditions and the following disclaimer must be |
||||
reproduced in the documentation and/or other materials provided with the distribution. |
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may |
||||
be used to endorse or promote products derived from this software without specific |
||||
prior written permission. |
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY |
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
||||
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
||||
SUCH DAMAGE. |
||||
|
||||
Portions of this software are copyright © 2023 The FreeType |
||||
Project (www.freetype.org). Please see LICENSE_FT.txt for more information. |
||||
All rights reserved. |
||||
*/ |
||||
#pragma endregion |
||||
#include "Audio.h" |
||||
#include "AdventuresInLestoria.h" |
||||
#include "DEFINES.h" |
||||
|
||||
INCLUDE_game |
||||
INCLUDE_DATA |
||||
|
||||
float Audio::defaultFadeTime; |
||||
|
||||
void Audio::Initialize(){ |
||||
Engine().SetBackgroundPlay(true); |
||||
Self().events.insert("Default Volume"); |
||||
for(auto&[key,data]:DATA["Events"]){ |
||||
Self().events.insert(key); |
||||
} |
||||
for(auto&[songFileName,size]:DATA["BGM"]){ |
||||
auto&data=DATA["BGM"][songFileName]; |
||||
if(songFileName!="Default Fade Time"){ |
||||
int channelCounter=0; |
||||
|
||||
BGM&bgm=Self().bgm[songFileName]; |
||||
|
||||
bgm.SetFileName(songFileName); |
||||
bgm.SetName(data["Track Name"].GetString()); |
||||
|
||||
while(data.HasProperty(std::format("channel[{}]",channelCounter))){ |
||||
std::string channelName=data[std::format("channel[{}]",channelCounter)].GetString(); |
||||
if(!std::filesystem::exists("bgm_directory"_S+channelName))ERR(std::format("WARNING! Could not load file {} for track {}",channelName,songFileName)); |
||||
bgm.AddChannel(channelName); |
||||
channelCounter++; |
||||
} |
||||
|
||||
if(!data.HasProperty("Default Volume"))ERR(std::format("WARNING! Track {} does not have a Default Volume parameter!",bgm.GetName())); |
||||
if(data["Default Volume"].GetValueCount()!=bgm.GetChannelCount())ERR(std::format("WARNING! Default Volume parameters do not match channel count. {} != {}",data["Default Volume"].GetValueCount(),bgm.GetChannelCount())); |
||||
|
||||
VolumeList volumes; |
||||
for(int i=0;i<data["Default Volume"].GetValueCount();i++){ |
||||
volumes.push_back(data["Default Volume"].GetInt(i)/100.f); |
||||
} |
||||
bgm.AddEventVolumes("Default Volume",volumes); |
||||
|
||||
if(data.HasProperty("Fade Time")){ |
||||
bgm.SetFadeTime(data["Fade Time"].GetReal()); |
||||
}else{ |
||||
bgm.SetFadeTime(defaultFadeTime); |
||||
} |
||||
|
||||
|
||||
if(data.HasProperty("Events")){ |
||||
for(auto&[eventName,size]:DATA["Events"]){ |
||||
auto&eventData=data["Events"][eventName]; |
||||
if(eventData.GetValueCount()!=bgm.GetChannelCount())ERR(std::format("WARNING! {} parameters do not match channel count. {} != {}",eventName,eventData.GetValueCount(),bgm.GetChannelCount())); |
||||
VolumeList volumes; |
||||
for(int i=0;i<eventData.GetValueCount();i++){ |
||||
volumes.push_back(eventData.GetInt(i)/100.f); |
||||
} |
||||
bgm.AddEventVolumes(eventName,volumes); |
||||
} |
||||
} |
||||
}else{ |
||||
defaultFadeTime=data.GetReal(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
MiniAudio&Audio::Engine(){ |
||||
return game->audioEngine.audioEngine; |
||||
} |
||||
void Audio::Play(const std::string_view sound){ |
||||
Engine().Play(std::string(sound)); |
||||
}; |
||||
void Audio::PlayBGM(const std::string_view sound,const bool loop){ |
||||
BGM&track=Self().bgm[std::string(sound)]; |
||||
StopBGM(); //Stop any currently playing track.
|
||||
Self().playParams={std::string(sound),loop}; |
||||
Self().playBGMWaitTime=0.7f; |
||||
}; |
||||
|
||||
void Audio::StopBGM(){ |
||||
if(Self().BGMIsPlaying()){ |
||||
BGM¤tTrack=Self().bgm[Self().currentBGM]; |
||||
for(int trackID:currentTrack.GetChannelIDs()){ |
||||
Engine().Stop(trackID); |
||||
} |
||||
} |
||||
} |
||||
|
||||
const bool Audio::BGMIsPlaying(){ |
||||
return Self().currentBGM.length()>0; |
||||
} |
||||
|
||||
const Volume&Audio::BGM::GetVolume(const Event&eventName,const ChannelID&id)const{ |
||||
return eventVolumes.GetVolumes(eventName).at(id); |
||||
} |
||||
|
||||
void Audio::BGM::Load(){ |
||||
BGM&bgm=Self().bgm[Self().currentBGM]; |
||||
if(Self().BGMIsPlaying()){ |
||||
bgm.Unload(); |
||||
} |
||||
Self().currentBGM=songFileName; |
||||
BGM&newBgm=Self().bgm[songFileName]; |
||||
if(newBgm.channels.size()>0)ERR(std::format("WARNING! The size of the channels list is greater than zero! Size: {}",bgm.channels.size())); |
||||
for(const ChannelName&channel:newBgm.GetChannels()){ |
||||
ChannelID soundID=Engine().LoadSound("bgm_directory"_S+channel); |
||||
newBgm.channels.push_back(soundID); |
||||
} |
||||
} |
||||
|
||||
void Audio::BGM::Unload(){ |
||||
BGM&bgm=Self().bgm[Self().currentBGM]; |
||||
for(const ChannelID&id:channels){ |
||||
Engine().UnloadSound(id); |
||||
} |
||||
channels.clear(); |
||||
Self().currentBGM=""; |
||||
} |
||||
|
||||
const ChannelID&Audio::BGM::GetChannelID(const int index){ |
||||
return channels[index]; |
||||
} |
||||
|
||||
const ChannelIDList&Audio::BGM::GetChannelIDs()const{ |
||||
return channels; |
||||
} |
||||
|
||||
const std::vector<ChannelName>&Audio::BGM::GetChannels()const{ |
||||
return channelNames; |
||||
} |
||||
|
||||
void Audio::BGM::SetFadeTime(const float fadeTime){ |
||||
this->fadeTime=fadeTime; |
||||
} |
||||
|
||||
void Audio::BGM::AddEventVolumes(const Event&eventName,const VolumeList&volumes){ |
||||
eventVolumes.AddEventInfo(eventName,volumes); |
||||
} |
||||
|
||||
const size_t Audio::BGM::GetChannelCount()const{ |
||||
return channelNames.size(); |
||||
} |
||||
|
||||
const SongName&Audio::BGM::GetName()const{ |
||||
return songName; |
||||
} |
||||
|
||||
void Audio::BGM::SetName(std::string_view name){ |
||||
songName=name; |
||||
} |
||||
|
||||
void Audio::BGM::SetFileName(std::string_view name){ |
||||
songFileName=name; |
||||
} |
||||
|
||||
void Audio::BGM::AddChannel(const ChannelName&name){ |
||||
channelNames.push_back(name); |
||||
} |
||||
|
||||
const VolumeList&Audio::EventData::GetVolumes(const Event&event)const{ |
||||
if(eventInfo.find(event)!=eventInfo.end())return eventInfo.at(event); |
||||
return eventInfo.at("Default Volume"); |
||||
} |
||||
|
||||
void Audio::EventData::AddEventInfo(const Event&eventName,const VolumeList&volumes){ |
||||
eventInfo[eventName]=volumes; |
||||
} |
||||
|
||||
Audio&Audio::Self(){ |
||||
return game->audioEngine; |
||||
} |
||||
|
||||
const Event&Audio::GetAudioEvent(){ |
||||
return Self().currentAudioEvent; |
||||
} |
||||
void Audio::SetAudioEvent(const Event&eventName){ |
||||
if(Self().events.find(eventName)==Self().events.end())ERR(std::format("WARNING! cannot find event {}",eventName)); |
||||
|
||||
Self().currentAudioEvent=eventName; |
||||
|
||||
if(Audio::BGMIsPlaying()){ |
||||
BGM¤tBgm=Self().bgm[Self().currentBGM]; |
||||
for(int currentTrackIndex=0;int trackID:currentBgm.GetChannelIDs()){ |
||||
Engine().SetVolume(trackID,currentBgm.GetVolume(eventName,currentTrackIndex)); |
||||
currentTrackIndex++; |
||||
} |
||||
} |
||||
} |
||||
|
||||
std::string operator""_SFX(const char*key,size_t length){ |
||||
return "sfx_directory"_S+std::string(key,length); |
||||
} |
||||
|
||||
const SongName&Audio::GetTrackName(){ |
||||
return Self().currentBGM; |
||||
} |
||||
|
||||
void Audio::Update(){ |
||||
if(Self().playBGMWaitTime>0.f){ |
||||
Self().playBGMWaitTime=std::max(Self().playBGMWaitTime-game->GetElapsedTime(),0.f); |
||||
if(Self().playBGMWaitTime==0.f){ |
||||
BGM&track=Self().bgm[Self().playParams.sound]; |
||||
track.Load(); |
||||
for(int channelListIndex=0;int trackID:track.GetChannelIDs()){ |
||||
Engine().SetVolume(trackID,track.GetVolume(Self().currentAudioEvent,channelListIndex)); |
||||
Engine().Play(trackID,Self().playParams.loop); |
||||
channelListIndex++; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,112 @@ |
||||
#pragma region License |
||||
/*
|
||||
License (OLC-3) |
||||
~~~~~~~~~~~~~~~ |
||||
|
||||
Copyright 2024 Joshua Sigona <sigonasr2@gmail.com> |
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, |
||||
are permitted provided that the following conditions are met: |
||||
|
||||
1. Redistributions or derivations of source code must retain the above copyright |
||||
notice, this list of conditions and the following disclaimer. |
||||
|
||||
2. Redistributions or derivative works in binary form must reproduce the above |
||||
copyright notice. This list of conditions and the following disclaimer must be |
||||
reproduced in the documentation and/or other materials provided with the distribution. |
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may |
||||
be used to endorse or promote products derived from this software without specific |
||||
prior written permission. |
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY |
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
||||
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
||||
SUCH DAMAGE. |
||||
|
||||
Portions of this software are copyright © 2023 The FreeType |
||||
Project (www.freetype.org). Please see LICENSE_FT.txt for more information. |
||||
All rights reserved. |
||||
*/ |
||||
#pragma endregion |
||||
#pragma once |
||||
#include "olcPGEX_MiniAudio.h" |
||||
#include "config.h" |
||||
#include <set> |
||||
|
||||
using SongName=std::string; |
||||
using Event=std::string; |
||||
using ChannelName=std::string; |
||||
using ChannelID=int; |
||||
using ChannelIDList=std::vector<ChannelID>; |
||||
using Volume=float; |
||||
using VolumeList=std::vector<Volume>; |
||||
|
||||
class Audio{ |
||||
public: |
||||
static Audio&Self(); |
||||
static MiniAudio&Engine(); |
||||
static void Initialize(); |
||||
static void Update(); |
||||
static void Play(const std::string_view sound); |
||||
//Play a BGM given a name found in bgm.txt configuration file.
|
||||
static void PlayBGM(const std::string_view sound,const bool loop=true); |
||||
static void StopBGM(); |
||||
static const Event&GetAudioEvent(); |
||||
static const SongName&GetTrackName(); |
||||
static void SetAudioEvent(const Event&eventName); |
||||
static const bool BGMIsPlaying(); |
||||
private: |
||||
struct BGMPlayParams{ |
||||
std::string sound; |
||||
bool loop; |
||||
}; |
||||
class EventData{ |
||||
public: |
||||
void AddEventInfo(const Event&eventName,const VolumeList&volumes); |
||||
const VolumeList&GetVolumes(const Event&event)const; |
||||
private: |
||||
std::map<Event,VolumeList>eventInfo; |
||||
}; |
||||
class BGM{ |
||||
public: |
||||
void Load(); |
||||
const size_t GetChannelCount()const; |
||||
const std::vector<ChannelName>&GetChannels()const; |
||||
const SongName&GetName()const; |
||||
const Volume&GetVolume(const Event&eventName,const ChannelID&id)const; |
||||
void SetName(std::string_view name); |
||||
void SetFileName(std::string_view name); |
||||
void AddChannel(const ChannelName&name); |
||||
void AddEventVolumes(const Event&eventName,const VolumeList&volumes); |
||||
void SetFadeTime(const float fadeTime); |
||||
const ChannelID&GetChannelID(const int index); |
||||
const ChannelIDList&GetChannelIDs()const; |
||||
private: |
||||
std::string songName; //Name of the track.
|
||||
std::string songFileName; //Name of the key in bgm.
|
||||
ChannelIDList channels; |
||||
std::vector<ChannelName>channelNames; |
||||
EventData eventVolumes; |
||||
float fadeTime="BGM.Default Fade Time"_F; |
||||
void Unload(); |
||||
}; |
||||
private: |
||||
MiniAudio audioEngine; |
||||
SongName currentBGM=""; |
||||
std::map<SongName,BGM>bgm; |
||||
std::set<Event>events; |
||||
static float defaultFadeTime; |
||||
Event currentAudioEvent="Default Volume"; |
||||
|
||||
float playBGMWaitTime=0.0f; |
||||
BGMPlayParams playParams; |
||||
}; |
||||
|
||||
std::string operator""_SFX(const char*key,size_t length); |
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 164 KiB After Width: | Height: | Size: 164 KiB |
@ -0,0 +1,103 @@ |
||||
#pragma region License |
||||
/*
|
||||
License (OLC-3) |
||||
~~~~~~~~~~~~~~~ |
||||
|
||||
Copyright 2024 Joshua Sigona <sigonasr2@gmail.com> |
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, |
||||
are permitted provided that the following conditions are met: |
||||
|
||||
1. Redistributions or derivations of source code must retain the above copyright |
||||
notice, this list of conditions and the following disclaimer. |
||||
|
||||
2. Redistributions or derivative works in binary form must reproduce the above |
||||
copyright notice. This list of conditions and the following disclaimer must be |
||||
reproduced in the documentation and/or other materials provided with the distribution. |
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may |
||||
be used to endorse or promote products derived from this software without specific |
||||
prior written permission. |
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY |
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
||||
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
||||
SUCH DAMAGE. |
||||
|
||||
Portions of this software are copyright © 2023 The FreeType |
||||
Project (www.freetype.org). Please see LICENSE_FT.txt for more information. |
||||
All rights reserved. |
||||
*/ |
||||
#pragma endregion |
||||
#pragma once |
||||
|
||||
#include "MenuComponent.h" |
||||
#include "ClassInfo.h" |
||||
|
||||
INCLUDE_ANIMATION_DATA |
||||
|
||||
class LoadFileButton:public MenuComponent{ |
||||
double playTime=-1; |
||||
int chapter=-1; |
||||
int level=-1; |
||||
std::string className=""; |
||||
std::string saveFileName=""; |
||||
int saveFileID=-1; |
||||
float animationTime=0; |
||||
public: |
||||
inline LoadFileButton(geom2d::rect<float>rect,const utils::datafile&metadata,const int saveFileID,MenuFunc onClick,ButtonAttr attributes) |
||||
:MenuComponent(rect,"",onClick,attributes),playTime(metadata.GetReal(0U)),chapter(metadata.GetInt(1U)),level(metadata.GetInt(2U)),className(metadata.GetString(3U)),saveFileName(metadata.GetString(4U)),saveFileID(saveFileID){ |
||||
showDefaultLabel=false; |
||||
} |
||||
|
||||
inline void Update(AiL*game)override{ |
||||
MenuComponent::Update(game); |
||||
if(playTime==-1){ |
||||
grayedOut=true; |
||||
} |
||||
animationTime+=game->GetElapsedTime(); |
||||
} |
||||
|
||||
inline void DrawDecal(ViewPort&window,bool focused)override{ |
||||
MenuComponent::DrawDecal(window,focused); |
||||
|
||||
if(playTime==-1){ |
||||
window.DrawShadowStringPropDecal(rect.pos+vf2d{2,2},"UNKNOWN"); |
||||
}else{ |
||||
window.DrawShadowStringPropDecal(rect.pos+vf2d{2,2},saveFileName); |
||||
|
||||
const std::map<std::string,std::string>classAnimations={ |
||||
{Warrior::name,Warrior::walk_s}, |
||||
{Ranger::name,Ranger::walk_s}, |
||||
{Wizard::name,Wizard::walk_s}, |
||||
{Thief::name,Thief::walk_s}, |
||||
{Trapper::name,Trapper::walk_s}, |
||||
{Witch::name,Witch::walk_s}, |
||||
}; |
||||
|
||||
std::string chapterText=std::format("Ch.{}",chapter); |
||||
vf2d chapterTextSize=game->GetTextSize(chapterText); |
||||
window.DrawShadowStringDecal(rect.pos+vf2d{rect.size.x-chapterTextSize.x-2,2},chapterText); |
||||
|
||||
const Animate2D::Frame&frame=ANIMATION_DATA[classAnimations.at(className)].GetFrame(animationTime); |
||||
geom2d::rect<int>sprRect=frame.GetSourceRect(); |
||||
window.DrawPartialDecal(rect.pos+vf2d{rect.size.x-26,rect.size.y-36},sprRect.size,frame.GetSourceImage()->Decal(),sprRect.pos,sprRect.size); |
||||
std::string levelClassText=std::format("Lv{} {}",level,className); |
||||
vf2d levelClassTextSize=game->GetTextSize(levelClassText); |
||||
window.DrawShadowStringDecal(rect.pos+vf2d{rect.size.x-levelClassTextSize.x-2,rect.size.y-10},levelClassText); |
||||
|
||||
window.DrawShadowStringDecal(rect.pos+vf2d{2,12},util::timerStr(playTime)); |
||||
|
||||
} |
||||
} |
||||
|
||||
inline const int&getSaveFileID()const{ |
||||
return saveFileID; |
||||
} |
||||
}; |
@ -0,0 +1,84 @@ |
||||
#pragma region License |
||||
/*
|
||||
License (OLC-3) |
||||
~~~~~~~~~~~~~~~ |
||||
|
||||
Copyright 2024 Joshua Sigona <sigonasr2@gmail.com> |
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, |
||||
are permitted provided that the following conditions are met: |
||||
|
||||
1. Redistributions or derivations of source code must retain the above copyright |
||||
notice, this list of conditions and the following disclaimer. |
||||
|
||||
2. Redistributions or derivative works in binary form must reproduce the above |
||||
copyright notice. This list of conditions and the following disclaimer must be |
||||
reproduced in the documentation and/or other materials provided with the distribution. |
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may |
||||
be used to endorse or promote products derived from this software without specific |
||||
prior written permission. |
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY |
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
||||
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
||||
SUCH DAMAGE. |
||||
|
||||
Portions of this software are copyright © 2023 The FreeType |
||||
Project (www.freetype.org). Please see LICENSE_FT.txt for more information. |
||||
All rights reserved. |
||||
*/ |
||||
#pragma endregion |
||||
#include "AdventuresInLestoria.h" |
||||
#include "DEFINES.h" |
||||
#include "Menu.h" |
||||
#include "MenuComponent.h" |
||||
#include "SaveFile.h" |
||||
|
||||
INCLUDE_game |
||||
using A=Attribute; |
||||
|
||||
void Menu::InitializeMainMenuWindow(){ |
||||
Menu*mainMenuWindow=CreateMenu(MAIN_MENU,vi2d{132,120},vi2d{96,96}); |
||||
|
||||
mainMenuWindow->ADD("New Game Button",MenuComponent)({{12,4},{72,24}},"New Game",[&](MenuFuncData data){ |
||||
game->TextEntryEnable(true); |
||||
#ifdef __EMSCRIPTEN__ |
||||
data.menu.S(A::NEXT_MENU)="New Game"; |
||||
if(SaveFile::GetUserID().length()==0){ |
||||
Menu::OpenMenu(USER_ID); |
||||
}else{ |
||||
Menu::OpenMenu(SAVE_FILE_NAME); |
||||
} |
||||
#else |
||||
Menu::OpenMenu(SAVE_FILE_NAME); |
||||
#endif |
||||
return true; |
||||
})END; |
||||
mainMenuWindow->ADD("Load Game Button",MenuComponent)({{12,36},{72,24}},"Load Game",[](MenuFuncData data){ |
||||
#ifdef __EMSCRIPTEN__ |
||||
data.menu.S(A::NEXT_MENU)="Load Game"; |
||||
if(SaveFile::GetUserID().length()==0){ |
||||
game->TextEntryEnable(true); |
||||
Menu::OpenMenu(USER_ID); |
||||
}else{ |
||||
SaveFile::UpdateSaveGameData(); |
||||
Menu::OpenMenu(LOAD_GAME); |
||||
} |
||||
#else |
||||
SaveFile::UpdateSaveGameData(); |
||||
Menu::OpenMenu(LOAD_GAME); |
||||
#endif |
||||
return true; |
||||
})END; |
||||
mainMenuWindow->ADD("Quit Game Button",MenuComponent)({{12,68},{72,24}},"Quit Game",[](MenuFuncData data){ |
||||
game->EndGame(); |
||||
return true; |
||||
})END; |
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue