The open source repository for the action RPG game in development by Sig Productions titled 'Adventures in Lestoria'!
https://forums.lestoria.net
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
170 lines
5.0 KiB
170 lines
5.0 KiB
1 year ago
|
#pragma region License
|
||
|
/*
|
||
|
License (OLC-3)
|
||
|
~~~~~~~~~~~~~~~
|
||
|
|
||
11 months ago
|
Copyright 2024 Joshua Sigona <sigonasr2@gmail.com>
|
||
1 year ago
|
|
||
|
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.
|
||
1 year ago
|
|
||
|
Portions of this software are copyright © 2023 The FreeType
|
||
|
Project (www.freetype.org). Please see LICENSE_FT.txt for more information.
|
||
|
All rights reserved.
|
||
1 year ago
|
*/
|
||
|
#pragma endregion
|
||
|
#include <string>
|
||
|
#include <vector>
|
||
|
#include <memory>
|
||
|
#include "safemap.h"
|
||
1 year ago
|
#include <set>
|
||
1 year ago
|
#include "olcPGEX_TTF.h"
|
||
1 year ago
|
|
||
|
class VisualNovel;
|
||
|
|
||
1 year ago
|
namespace CommandType{
|
||
|
enum CommandType{
|
||
|
PAUSE,
|
||
|
DIALOG,
|
||
|
SPEAKER,
|
||
|
BACKGROUND,
|
||
|
RIGHT,
|
||
|
LEFT,
|
||
|
LOCATION
|
||
|
};
|
||
|
}
|
||
|
|
||
1 year ago
|
class Command{
|
||
1 year ago
|
friend class VisualNovel;
|
||
1 year ago
|
virtual void Execute(VisualNovel&vn)=0;
|
||
|
protected:
|
||
|
Command();
|
||
1 year ago
|
public:
|
||
|
virtual CommandType::CommandType GetType()=0;
|
||
1 year ago
|
};
|
||
|
|
||
1 year ago
|
class PauseCommand final:public Command{
|
||
|
public:
|
||
|
void Execute(VisualNovel&vn)override;
|
||
|
PauseCommand();
|
||
1 year ago
|
CommandType::CommandType GetType()final override;
|
||
1 year ago
|
};
|
||
|
|
||
|
class DialogCommand final:public Command{
|
||
|
std::string dialog;
|
||
|
public:
|
||
|
void Execute(VisualNovel&vn)override;
|
||
|
DialogCommand(std::string dialog);
|
||
1 year ago
|
CommandType::CommandType GetType()final override;
|
||
1 year ago
|
};
|
||
|
|
||
|
class SpeakerCommand final:public Command{
|
||
|
std::string displayedName;
|
||
|
std::string actualSpeakerName;
|
||
|
public:
|
||
|
void Execute(VisualNovel&vn)override;
|
||
|
SpeakerCommand(std::string speaker);
|
||
|
SpeakerCommand(std::string displayedName,std::string speaker);
|
||
1 year ago
|
CommandType::CommandType GetType()final override;
|
||
1 year ago
|
};
|
||
|
|
||
|
class BackgroundCommand final:public Command{
|
||
|
std::string backgroundFilename;
|
||
|
public:
|
||
|
void Execute(VisualNovel&vn)override;
|
||
|
BackgroundCommand(std::string backgroundFilename);
|
||
1 year ago
|
CommandType::CommandType GetType()final override;
|
||
1 year ago
|
};
|
||
|
|
||
|
class RightCommand final:public Command{
|
||
|
std::vector<std::string>characters;
|
||
|
public:
|
||
|
void Execute(VisualNovel&vn)override;
|
||
|
RightCommand(std::vector<std::string>characters);
|
||
1 year ago
|
CommandType::CommandType GetType()final override;
|
||
1 year ago
|
};
|
||
|
|
||
|
class LeftCommand final:public Command{
|
||
|
std::vector<std::string>characters;
|
||
|
public:
|
||
|
void Execute(VisualNovel&vn)override;
|
||
|
LeftCommand(std::vector<std::string>characters);
|
||
1 year ago
|
CommandType::CommandType GetType()final override;
|
||
1 year ago
|
};
|
||
|
|
||
|
class LocationCommand final:public Command{
|
||
|
std::string location;
|
||
|
public:
|
||
|
void Execute(VisualNovel&vn)override;
|
||
|
LocationCommand(std::string location);
|
||
1 year ago
|
CommandType::CommandType GetType()final override;
|
||
1 year ago
|
};
|
||
|
|
||
|
class VisualNovel{
|
||
1 year ago
|
friend class State_Story;
|
||
11 months ago
|
friend class AiL;
|
||
1 year ago
|
friend class Command;
|
||
|
friend class LocationCommand;
|
||
|
friend class BackgroundCommand;
|
||
|
friend class LeftCommand;
|
||
|
friend class RightCommand;
|
||
|
friend class SpeakerCommand;
|
||
|
friend class DialogCommand;
|
||
|
friend class PauseCommand;
|
||
1 year ago
|
std::string storyLevel;
|
||
1 year ago
|
std::u32string speakerDisplayName=U"";
|
||
|
std::u32string actualSpeakerName=U"";
|
||
|
std::u32string activeText;
|
||
1 year ago
|
std::vector<std::string>leftCharacters;
|
||
|
std::vector<std::string>rightCharacters;
|
||
|
std::string backgroundFilename;
|
||
1 year ago
|
std::string prevBackgroundFilename;
|
||
|
float transitionTime=0;
|
||
1 year ago
|
static constexpr float maxTransitionTime=2.0f;
|
||
1 year ago
|
std::vector<Command*>commands;
|
||
1 year ago
|
int commandIndex=0;
|
||
1 year ago
|
std::string locationDisplayText="";
|
||
|
float locationDisplayTime=0;
|
||
|
std::string prevTheme="";
|
||
1 year ago
|
float textScrollTime=0;
|
||
|
static constexpr float maxTextScrollTime=1.0f;
|
||
12 months ago
|
public:
|
||
1 year ago
|
static Font font,narratorFont,locationFont;
|
||
12 months ago
|
private:
|
||
1 year ago
|
static std::set<std::string>graphicsToLoad;
|
||
1 year ago
|
static safemap<std::string,std::vector<std::unique_ptr<Command>>>storyLevelData;
|
||
|
|
||
|
static VisualNovel novel;
|
||
1 year ago
|
VisualNovel();
|
||
1 year ago
|
public:
|
||
|
VisualNovel(VisualNovel&)=delete;
|
||
|
VisualNovel(VisualNovel&&)=delete;
|
||
|
static void Initialize();
|
||
|
static void LoadVisualNovel(std::string storyLevelName);
|
||
1 year ago
|
void ExecuteNextCommand();
|
||
|
void Update();
|
||
|
void Draw();
|
||
1 year ago
|
std::string GetCharacterImage(std::u32string name);
|
||
1 year ago
|
};
|