OpenXcom  1.0
Open-source clone of the original X-Com
Ufopaedia.h
1 #pragma once
2 /*
3  * Copyright 2010-2016 OpenXcom Developers.
4  *
5  * This file is part of OpenXcom.
6  *
7  * OpenXcom is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * OpenXcom is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with OpenXcom. If not, see <http://www.gnu.org/licenses/>.
19  */
20 #include <vector>
21 #include <string>
22 
23 namespace OpenXcom
24 {
25  class Game;
26  class SavedGame;
27  class Mod;
28  class ArticleDefinition;
29  class ArticleState;
30 
32  typedef std::vector<ArticleDefinition *> ArticleDefinitionList;
33 
34  // This section is meant for articles, that have to be activated,
35  // but have no own entry in a list. E.g. Ammunition items.
36  // Maybe others as well, that should just not be selectable.
37  static const std::string UFOPAEDIA_NOT_AVAILABLE = "STR_NOT_AVAILABLE";
38 
46  class Ufopaedia
47  {
48  public:
50  static bool isArticleAvailable(SavedGame *save, ArticleDefinition *article);
51 
53  static void openArticle(Game *game, const std::string &article_id);
54 
56  static void openArticle(Game *game, ArticleDefinition *article);
57 
59  static void open(Game *game);
60 
62  static void next(Game *game);
63 
65  static void prev(Game *game);
66 
68  static void list(SavedGame *save, Mod *rule, const std::string &section, ArticleDefinitionList &data);
69 
70  protected:
71 
73  static size_t _current_index;
74 
76  static size_t getArticleIndex(SavedGame *save, Mod *rule, std::string &article_id);
77 
79  static ArticleDefinitionList getAvailableArticles(SavedGame *save, Mod *rule);
80 
83  };
84 }
The game data that gets written to disk when the game is saved.
Definition: SavedGame.h:99
static bool isArticleAvailable(SavedGame *save, ArticleDefinition *article)
check, if a specific article is currently available.
Definition: Ufopaedia.cpp:55
Contains all the game-specific static data that never changes throughout the game, like rulesets and resources.
Definition: Mod.h:87
static void prev(Game *game)
article navigation to previous article.
Definition: Ufopaedia.cpp:214
static void openArticle(Game *game, const std::string &article_id)
open Ufopaedia on a certain entry.
Definition: Ufopaedia.cpp:170
static void list(SavedGame *save, Mod *rule, const std::string &section, ArticleDefinitionList &data)
load a vector with article ids that are currently visible of a given section.
Definition: Ufopaedia.cpp:237
static void open(Game *game)
open Ufopaedia with selection dialog.
Definition: Ufopaedia.cpp:185
static size_t getArticleIndex(SavedGame *save, Mod *rule, std::string &article_id)
get index of the given article id in the visible list.
Definition: Ufopaedia.cpp:68
ArticleDefinition is the base class for all article types.
Definition: ArticleDefinition.h:54
static ArticleDefinitionList getAvailableArticles(SavedGame *save, Mod *rule)
get list of researched articles
Definition: Ufopaedia.cpp:255
UfopaediaArticle is the base class for all articles of various types.
Definition: ArticleState.h:37
The core of the game engine, manages the game&#39;s entire contents and structure.
Definition: Game.h:41
static size_t _current_index
current selected article index (for prev/next navigation).
Definition: Ufopaedia.h:73
static void next(Game *game)
article navigation to next article.
Definition: Ufopaedia.cpp:194
static ArticleState * createArticleState(ArticleDefinition *article)
create a new state object from article definition.
Definition: Ufopaedia.cpp:107
Definition: BaseInfoState.cpp:40
This static class encapsulates all functions related to Ufopaedia for the game.
Definition: Ufopaedia.h:46