Merge branch 'master' into jgrpp
# Conflicts: # src/core/sort_func.hpp # src/rail_cmd.cpp # src/timetable_cmd.cpp # src/video/sdl_v.cpp # src/video/win32_v.cpp
This commit is contained in:
@@ -777,7 +777,6 @@
|
|||||||
<ClInclude Include="..\src\core\smallmatrix_type.hpp" />
|
<ClInclude Include="..\src\core\smallmatrix_type.hpp" />
|
||||||
<ClInclude Include="..\src\core\smallstack_type.hpp" />
|
<ClInclude Include="..\src\core\smallstack_type.hpp" />
|
||||||
<ClInclude Include="..\src\core\smallvec_type.hpp" />
|
<ClInclude Include="..\src\core\smallvec_type.hpp" />
|
||||||
<ClInclude Include="..\src\core\sort_func.hpp" />
|
|
||||||
<ClInclude Include="..\src\core\string_compare_type.hpp" />
|
<ClInclude Include="..\src\core\string_compare_type.hpp" />
|
||||||
<ClCompile Include="..\src\aircraft_gui.cpp" />
|
<ClCompile Include="..\src\aircraft_gui.cpp" />
|
||||||
<ClCompile Include="..\src\airport_gui.cpp" />
|
<ClCompile Include="..\src\airport_gui.cpp" />
|
||||||
|
@@ -1425,9 +1425,6 @@
|
|||||||
<ClInclude Include="..\src\core\smallvec_type.hpp">
|
<ClInclude Include="..\src\core\smallvec_type.hpp">
|
||||||
<Filter>Core Source Code</Filter>
|
<Filter>Core Source Code</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\src\core\sort_func.hpp">
|
|
||||||
<Filter>Core Source Code</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\src\core\string_compare_type.hpp">
|
<ClInclude Include="..\src\core\string_compare_type.hpp">
|
||||||
<Filter>Core Source Code</Filter>
|
<Filter>Core Source Code</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@@ -777,7 +777,6 @@
|
|||||||
<ClInclude Include="..\src\core\smallmatrix_type.hpp" />
|
<ClInclude Include="..\src\core\smallmatrix_type.hpp" />
|
||||||
<ClInclude Include="..\src\core\smallstack_type.hpp" />
|
<ClInclude Include="..\src\core\smallstack_type.hpp" />
|
||||||
<ClInclude Include="..\src\core\smallvec_type.hpp" />
|
<ClInclude Include="..\src\core\smallvec_type.hpp" />
|
||||||
<ClInclude Include="..\src\core\sort_func.hpp" />
|
|
||||||
<ClInclude Include="..\src\core\string_compare_type.hpp" />
|
<ClInclude Include="..\src\core\string_compare_type.hpp" />
|
||||||
<ClCompile Include="..\src\aircraft_gui.cpp" />
|
<ClCompile Include="..\src\aircraft_gui.cpp" />
|
||||||
<ClCompile Include="..\src\airport_gui.cpp" />
|
<ClCompile Include="..\src\airport_gui.cpp" />
|
||||||
|
@@ -1425,9 +1425,6 @@
|
|||||||
<ClInclude Include="..\src\core\smallvec_type.hpp">
|
<ClInclude Include="..\src\core\smallvec_type.hpp">
|
||||||
<Filter>Core Source Code</Filter>
|
<Filter>Core Source Code</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\src\core\sort_func.hpp">
|
|
||||||
<Filter>Core Source Code</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\src\core\string_compare_type.hpp">
|
<ClInclude Include="..\src\core\string_compare_type.hpp">
|
||||||
<Filter>Core Source Code</Filter>
|
<Filter>Core Source Code</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@@ -777,7 +777,6 @@
|
|||||||
<ClInclude Include="..\src\core\smallmatrix_type.hpp" />
|
<ClInclude Include="..\src\core\smallmatrix_type.hpp" />
|
||||||
<ClInclude Include="..\src\core\smallstack_type.hpp" />
|
<ClInclude Include="..\src\core\smallstack_type.hpp" />
|
||||||
<ClInclude Include="..\src\core\smallvec_type.hpp" />
|
<ClInclude Include="..\src\core\smallvec_type.hpp" />
|
||||||
<ClInclude Include="..\src\core\sort_func.hpp" />
|
|
||||||
<ClInclude Include="..\src\core\string_compare_type.hpp" />
|
<ClInclude Include="..\src\core\string_compare_type.hpp" />
|
||||||
<ClCompile Include="..\src\aircraft_gui.cpp" />
|
<ClCompile Include="..\src\aircraft_gui.cpp" />
|
||||||
<ClCompile Include="..\src\airport_gui.cpp" />
|
<ClCompile Include="..\src\airport_gui.cpp" />
|
||||||
|
@@ -1425,9 +1425,6 @@
|
|||||||
<ClInclude Include="..\src\core\smallvec_type.hpp">
|
<ClInclude Include="..\src\core\smallvec_type.hpp">
|
||||||
<Filter>Core Source Code</Filter>
|
<Filter>Core Source Code</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\src\core\sort_func.hpp">
|
|
||||||
<Filter>Core Source Code</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\src\core\string_compare_type.hpp">
|
<ClInclude Include="..\src\core\string_compare_type.hpp">
|
||||||
<Filter>Core Source Code</Filter>
|
<Filter>Core Source Code</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@@ -483,7 +483,6 @@ core/smallmap_type.hpp
|
|||||||
core/smallmatrix_type.hpp
|
core/smallmatrix_type.hpp
|
||||||
core/smallstack_type.hpp
|
core/smallstack_type.hpp
|
||||||
core/smallvec_type.hpp
|
core/smallvec_type.hpp
|
||||||
core/sort_func.hpp
|
|
||||||
core/string_compare_type.hpp
|
core/string_compare_type.hpp
|
||||||
|
|
||||||
# GUI Source Code
|
# GUI Source Code
|
||||||
|
@@ -57,7 +57,7 @@ public:
|
|||||||
* Initialize the BitmapTileArea with the specified Rect.
|
* Initialize the BitmapTileArea with the specified Rect.
|
||||||
* @param rect Rect to use.
|
* @param rect Rect to use.
|
||||||
*/
|
*/
|
||||||
void Initialize(Rect r)
|
void Initialize(const Rect &r)
|
||||||
{
|
{
|
||||||
this->tile = TileXY(r.left, r.top);
|
this->tile = TileXY(r.left, r.top);
|
||||||
this->w = r.right - r.left + 1;
|
this->w = r.right - r.left + 1;
|
||||||
@@ -66,6 +66,15 @@ public:
|
|||||||
this->data.resize(Index(w, h));
|
this->data.resize(Index(w, h));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Initialize(const TileArea &ta)
|
||||||
|
{
|
||||||
|
this->tile = ta.tile;
|
||||||
|
this->w = ta.w;
|
||||||
|
this->h = ta.h;
|
||||||
|
this->data.clear();
|
||||||
|
this->data.resize(Index(w, h));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a tile as part of the tile area.
|
* Add a tile as part of the tile area.
|
||||||
* @param tile Tile to add.
|
* @param tile Tile to add.
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
#include "newgrf_cargo.h"
|
#include "newgrf_cargo.h"
|
||||||
#include "string_func.h"
|
#include "string_func.h"
|
||||||
#include "strings_func.h"
|
#include "strings_func.h"
|
||||||
#include "core/sort_func.hpp"
|
#include <algorithm>
|
||||||
|
|
||||||
#include "table/sprites.h"
|
#include "table/sprites.h"
|
||||||
#include "table/strings.h"
|
#include "table/strings.h"
|
||||||
@@ -132,56 +132,54 @@ SpriteID CargoSpec::GetCargoIcon() const
|
|||||||
return sprite;
|
return sprite;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CargoSpec *_sorted_cargo_specs[NUM_CARGO]; ///< Cargo specifications sorted alphabetically by name.
|
std::vector<const CargoSpec *> _sorted_cargo_specs; ///< Cargo specifications sorted alphabetically by name.
|
||||||
uint8 _sorted_cargo_specs_size; ///< Number of cargo specifications stored at the _sorted_cargo_specs array (including special cargoes).
|
uint8 _sorted_standard_cargo_specs_size; ///< Number of standard cargo specifications stored in the _sorted_cargo_specs array.
|
||||||
uint8 _sorted_standard_cargo_specs_size; ///< Number of standard cargo specifications stored at the _sorted_cargo_specs array.
|
|
||||||
|
|
||||||
|
|
||||||
/** Sort cargo specifications by their name. */
|
/** Sort cargo specifications by their name. */
|
||||||
static int CDECL CargoSpecNameSorter(const CargoSpec * const *a, const CargoSpec * const *b)
|
static bool CargoSpecNameSorter(const CargoSpec * const &a, const CargoSpec * const &b)
|
||||||
{
|
{
|
||||||
static char a_name[64];
|
static char a_name[64];
|
||||||
static char b_name[64];
|
static char b_name[64];
|
||||||
|
|
||||||
GetString(a_name, (*a)->name, lastof(a_name));
|
GetString(a_name, a->name, lastof(a_name));
|
||||||
GetString(b_name, (*b)->name, lastof(b_name));
|
GetString(b_name, b->name, lastof(b_name));
|
||||||
|
|
||||||
int res = strnatcmp(a_name, b_name); // Sort by name (natural sorting).
|
int res = strnatcmp(a_name, b_name); // Sort by name (natural sorting).
|
||||||
|
|
||||||
/* If the names are equal, sort by cargo bitnum. */
|
/* If the names are equal, sort by cargo bitnum. */
|
||||||
return (res != 0) ? res : ((*a)->bitnum - (*b)->bitnum);
|
return (res != 0) ? res < 0 : (a->bitnum < b->bitnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Sort cargo specifications by their cargo class. */
|
/** Sort cargo specifications by their cargo class. */
|
||||||
static int CDECL CargoSpecClassSorter(const CargoSpec * const *a, const CargoSpec * const *b)
|
static bool CargoSpecClassSorter(const CargoSpec * const &a, const CargoSpec * const &b)
|
||||||
{
|
{
|
||||||
int res = ((*b)->classes & CC_PASSENGERS) - ((*a)->classes & CC_PASSENGERS);
|
int res = (b->classes & CC_PASSENGERS) - (a->classes & CC_PASSENGERS);
|
||||||
if (res == 0) {
|
if (res == 0) {
|
||||||
res = ((*b)->classes & CC_MAIL) - ((*a)->classes & CC_MAIL);
|
res = (b->classes & CC_MAIL) - (a->classes & CC_MAIL);
|
||||||
if (res == 0) {
|
if (res == 0) {
|
||||||
res = ((*a)->classes & CC_SPECIAL) - ((*b)->classes & CC_SPECIAL);
|
res = (a->classes & CC_SPECIAL) - (b->classes & CC_SPECIAL);
|
||||||
if (res == 0) {
|
if (res == 0) {
|
||||||
return CargoSpecNameSorter(a, b);
|
return CargoSpecNameSorter(a, b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Initialize the list of sorted cargo specifications. */
|
/** Initialize the list of sorted cargo specifications. */
|
||||||
void InitializeSortedCargoSpecs()
|
void InitializeSortedCargoSpecs()
|
||||||
{
|
{
|
||||||
_sorted_cargo_specs_size = 0;
|
_sorted_cargo_specs.clear();
|
||||||
const CargoSpec *cargo;
|
const CargoSpec *cargo;
|
||||||
/* Add each cargo spec to the list. */
|
/* Add each cargo spec to the list. */
|
||||||
FOR_ALL_CARGOSPECS(cargo) {
|
FOR_ALL_CARGOSPECS(cargo) {
|
||||||
_sorted_cargo_specs[_sorted_cargo_specs_size] = cargo;
|
_sorted_cargo_specs.push_back(cargo);
|
||||||
_sorted_cargo_specs_size++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sort cargo specifications by cargo class and name. */
|
/* Sort cargo specifications by cargo class and name. */
|
||||||
QSortT(_sorted_cargo_specs, _sorted_cargo_specs_size, &CargoSpecClassSorter);
|
std::sort(_sorted_cargo_specs.begin(), _sorted_cargo_specs.end(), &CargoSpecClassSorter);
|
||||||
|
|
||||||
_standard_cargo_mask = 0;
|
_standard_cargo_mask = 0;
|
||||||
|
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
#include "gfx_type.h"
|
#include "gfx_type.h"
|
||||||
#include "strings_type.h"
|
#include "strings_type.h"
|
||||||
#include "landscape_type.h"
|
#include "landscape_type.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
/** Globally unique label of a cargo type. */
|
/** Globally unique label of a cargo type. */
|
||||||
typedef uint32 CargoLabel;
|
typedef uint32 CargoLabel;
|
||||||
@@ -137,8 +138,7 @@ CargoID GetCargoIDByLabel(CargoLabel cl);
|
|||||||
CargoID GetCargoIDByBitnum(uint8 bitnum);
|
CargoID GetCargoIDByBitnum(uint8 bitnum);
|
||||||
|
|
||||||
void InitializeSortedCargoSpecs();
|
void InitializeSortedCargoSpecs();
|
||||||
extern const CargoSpec *_sorted_cargo_specs[NUM_CARGO];
|
extern std::vector<const CargoSpec *> _sorted_cargo_specs;
|
||||||
extern uint8 _sorted_cargo_specs_size;
|
|
||||||
extern uint8 _sorted_standard_cargo_specs_size;
|
extern uint8 _sorted_standard_cargo_specs_size;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -163,7 +163,7 @@ static inline bool IsCargoInClass(CargoID c, CargoClass cc)
|
|||||||
* @param var Reference getting the cargospec.
|
* @param var Reference getting the cargospec.
|
||||||
* @see CargoSpec
|
* @see CargoSpec
|
||||||
*/
|
*/
|
||||||
#define FOR_ALL_SORTED_CARGOSPECS(var) for (uint8 index = 0; index < _sorted_cargo_specs_size && (var = _sorted_cargo_specs[index], true) ; index++)
|
#define FOR_ALL_SORTED_CARGOSPECS(var) for (uint8 index = 0; index < _sorted_cargo_specs.size() && (var = _sorted_cargo_specs[index], true) ; index++)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loop header for iterating over 'real' cargoes, sorted by name. Phony cargoes like regearing cargoes are skipped.
|
* Loop header for iterating over 'real' cargoes, sorted by name. Phony cargoes like regearing cargoes are skipped.
|
||||||
|
@@ -13,17 +13,17 @@
|
|||||||
#define ENUM_TYPE_HPP
|
#define ENUM_TYPE_HPP
|
||||||
|
|
||||||
/** Some enums need to have allowed incrementing (i.e. StationClassID) */
|
/** Some enums need to have allowed incrementing (i.e. StationClassID) */
|
||||||
#define DECLARE_POSTFIX_INCREMENT(type) \
|
#define DECLARE_POSTFIX_INCREMENT(enum_type) \
|
||||||
inline type operator ++(type& e, int) \
|
inline enum_type operator ++(enum_type& e, int) \
|
||||||
{ \
|
{ \
|
||||||
type e_org = e; \
|
enum_type e_org = e; \
|
||||||
e = (type)((int)e + 1); \
|
e = (enum_type)((std::underlying_type<enum_type>::type)e + 1); \
|
||||||
return e_org; \
|
return e_org; \
|
||||||
} \
|
} \
|
||||||
inline type operator --(type& e, int) \
|
inline enum_type operator --(enum_type& e, int) \
|
||||||
{ \
|
{ \
|
||||||
type e_org = e; \
|
enum_type e_org = e; \
|
||||||
e = (type)((int)e - 1); \
|
e = (enum_type)((std::underlying_type<enum_type>::type)e - 1); \
|
||||||
return e_org; \
|
return e_org; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,13 +31,13 @@
|
|||||||
|
|
||||||
/** Operators to allow to work with enum as with type safe bit set in C++ */
|
/** Operators to allow to work with enum as with type safe bit set in C++ */
|
||||||
# define DECLARE_ENUM_AS_BIT_SET(mask_t) \
|
# define DECLARE_ENUM_AS_BIT_SET(mask_t) \
|
||||||
inline mask_t operator | (mask_t m1, mask_t m2) {return (mask_t)((int)m1 | m2);} \
|
inline mask_t operator | (mask_t m1, mask_t m2) {return (mask_t)((std::underlying_type<mask_t>::type)m1 | m2);} \
|
||||||
inline mask_t operator & (mask_t m1, mask_t m2) {return (mask_t)((int)m1 & m2);} \
|
inline mask_t operator & (mask_t m1, mask_t m2) {return (mask_t)((std::underlying_type<mask_t>::type)m1 & m2);} \
|
||||||
inline mask_t operator ^ (mask_t m1, mask_t m2) {return (mask_t)((int)m1 ^ m2);} \
|
inline mask_t operator ^ (mask_t m1, mask_t m2) {return (mask_t)((std::underlying_type<mask_t>::type)m1 ^ m2);} \
|
||||||
inline mask_t& operator |= (mask_t& m1, mask_t m2) {m1 = m1 | m2; return m1;} \
|
inline mask_t& operator |= (mask_t& m1, mask_t m2) {m1 = m1 | m2; return m1;} \
|
||||||
inline mask_t& operator &= (mask_t& m1, mask_t m2) {m1 = m1 & m2; return m1;} \
|
inline mask_t& operator &= (mask_t& m1, mask_t m2) {m1 = m1 & m2; return m1;} \
|
||||||
inline mask_t& operator ^= (mask_t& m1, mask_t m2) {m1 = m1 ^ m2; return m1;} \
|
inline mask_t& operator ^= (mask_t& m1, mask_t m2) {m1 = m1 ^ m2; return m1;} \
|
||||||
inline mask_t operator ~(mask_t m) {return (mask_t)(~(int)m);}
|
inline mask_t operator ~(mask_t m) {return (mask_t)(~(std::underlying_type<mask_t>::type)m);}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -29,6 +29,20 @@ struct Point {
|
|||||||
struct Dimension {
|
struct Dimension {
|
||||||
uint width;
|
uint width;
|
||||||
uint height;
|
uint height;
|
||||||
|
|
||||||
|
Dimension(uint w = 0, uint h = 0) : width(w), height(h) {};
|
||||||
|
|
||||||
|
bool operator< (const Dimension &other) const
|
||||||
|
{
|
||||||
|
int x = (*this).width - other.width;
|
||||||
|
if (x != 0) return x < 0;
|
||||||
|
return (*this).height < other.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator== (const Dimension &other) const
|
||||||
|
{
|
||||||
|
return (*this).width == other.width && (*this).height == other.height;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Specification of a rectangle with absolute coordinates of all edges */
|
/** Specification of a rectangle with absolute coordinates of all edges */
|
||||||
|
@@ -13,7 +13,6 @@
|
|||||||
#define SMALLMAP_TYPE_HPP
|
#define SMALLMAP_TYPE_HPP
|
||||||
|
|
||||||
#include "smallvec_type.hpp"
|
#include "smallvec_type.hpp"
|
||||||
#include "sort_func.hpp"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple pair of data. Both types have to be POD ("Plain Old Data")!
|
* Simple pair of data. Both types have to be POD ("Plain Old Data")!
|
||||||
|
@@ -1,37 +0,0 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of OpenTTD.
|
|
||||||
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
|
||||||
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @file sort_func.hpp Functions related to sorting operations. */
|
|
||||||
|
|
||||||
#ifndef SORT_FUNC_HPP
|
|
||||||
#define SORT_FUNC_HPP
|
|
||||||
|
|
||||||
#include "mem_func.hpp"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Type safe qsort()
|
|
||||||
*
|
|
||||||
* @note Use this sort for irregular sorted data.
|
|
||||||
*
|
|
||||||
* @param base Pointer to the first element of the array to be sorted.
|
|
||||||
* @param num Number of elements in the array pointed by base.
|
|
||||||
* @param comparator Function that compares two elements.
|
|
||||||
* @param desc Sort descending.
|
|
||||||
*/
|
|
||||||
template <typename T>
|
|
||||||
static inline void QSortT(T *base, size_t num, int (CDECL *comparator)(const T*, const T*), bool desc = false)
|
|
||||||
{
|
|
||||||
if (num < 2) return;
|
|
||||||
|
|
||||||
qsort(base, num, sizeof(T), (int (CDECL *)(const void *, const void *))comparator);
|
|
||||||
|
|
||||||
if (desc) MemReverseT(base, num);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* SORT_FUNC_HPP */
|
|
@@ -30,7 +30,6 @@
|
|||||||
#include "order_base.h"
|
#include "order_base.h"
|
||||||
#include "settings_type.h"
|
#include "settings_type.h"
|
||||||
#include "core/smallvec_type.hpp"
|
#include "core/smallvec_type.hpp"
|
||||||
#include "core/sort_func.hpp"
|
|
||||||
#include "date_type.h"
|
#include "date_type.h"
|
||||||
#include "company_type.h"
|
#include "company_type.h"
|
||||||
#include "cargo_type.h"
|
#include "cargo_type.h"
|
||||||
@@ -190,8 +189,8 @@ static void ScheduledDispatchDepartureLocalFix(DepartureList *departure_list)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Re-sort the departure list */
|
/* Re-sort the departure list */
|
||||||
QSortT<Departure*>(departure_list->data(), departure_list->size(), [](Departure * const *a, Departure * const *b) -> int {
|
std::sort(departure_list->begin(), departure_list->end(), [](Departure * const &a, Departure * const &b) -> bool {
|
||||||
return (*a)->scheduled_date - (*b)->scheduled_date;
|
return a->scheduled_date < b->scheduled_date;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -18,18 +18,17 @@
|
|||||||
|
|
||||||
#include "safeguards.h"
|
#include "safeguards.h"
|
||||||
|
|
||||||
char *_ini_videodriver; ///< The video driver a stored in the configuration file.
|
char *_ini_videodriver; ///< The video driver a stored in the configuration file.
|
||||||
int _num_resolutions; ///< The number of resolutions.
|
std::vector<Dimension> _resolutions; ///< List of resolutions.
|
||||||
Dimension _resolutions[32]; ///< List of resolutions.
|
Dimension _cur_resolution; ///< The current resolution.
|
||||||
Dimension _cur_resolution; ///< The current resolution.
|
bool _rightclick_emulate; ///< Whether right clicking is emulated.
|
||||||
bool _rightclick_emulate; ///< Whether right clicking is emulated.
|
|
||||||
|
|
||||||
char *_ini_sounddriver; ///< The sound driver a stored in the configuration file.
|
char *_ini_sounddriver; ///< The sound driver a stored in the configuration file.
|
||||||
|
|
||||||
char *_ini_musicdriver; ///< The music driver a stored in the configuration file.
|
char *_ini_musicdriver; ///< The music driver a stored in the configuration file.
|
||||||
|
|
||||||
char *_ini_blitter; ///< The blitter as stored in the configuration file.
|
char *_ini_blitter; ///< The blitter as stored in the configuration file.
|
||||||
bool _blitter_autodetected; ///< Was the blitter autodetected or specified by the user?
|
bool _blitter_autodetected; ///< Was the blitter autodetected or specified by the user?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a string parameter the list of parameters.
|
* Get a string parameter the list of parameters.
|
||||||
|
11
src/fios.cpp
11
src/fios.cpp
@@ -52,16 +52,15 @@ extern void GetOldSaveGameName(const char *file, char *title, const char *last);
|
|||||||
*/
|
*/
|
||||||
bool FiosItem::operator< (const FiosItem &other) const
|
bool FiosItem::operator< (const FiosItem &other) const
|
||||||
{
|
{
|
||||||
bool r = false;
|
int r = false;
|
||||||
|
|
||||||
if ((_savegame_sort_order & SORT_BY_NAME) == 0 && (*this).mtime != other.mtime) {
|
if ((_savegame_sort_order & SORT_BY_NAME) == 0 && (*this).mtime != other.mtime) {
|
||||||
r = (*this).mtime < other.mtime;
|
r = (*this).mtime - other.mtime;
|
||||||
} else {
|
} else {
|
||||||
r = strcasecmp((*this).title, other.title) < 0;
|
r = strcasecmp((*this).title, other.title);
|
||||||
}
|
}
|
||||||
|
if (r == 0) return false;
|
||||||
if (_savegame_sort_order & SORT_DESCENDING) r = !r;
|
return (_savegame_sort_order & SORT_DESCENDING) ? r > 0 : r < 0;
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FileList::~FileList()
|
FileList::~FileList()
|
||||||
|
13
src/gfx.cpp
13
src/gfx.cpp
@@ -1694,20 +1694,13 @@ bool ChangeResInGame(int width, int height)
|
|||||||
bool ToggleFullScreen(bool fs)
|
bool ToggleFullScreen(bool fs)
|
||||||
{
|
{
|
||||||
bool result = VideoDriver::GetInstance()->ToggleFullscreen(fs);
|
bool result = VideoDriver::GetInstance()->ToggleFullscreen(fs);
|
||||||
if (_fullscreen != fs && _num_resolutions == 0) {
|
if (_fullscreen != fs && _resolutions.empty()) {
|
||||||
DEBUG(driver, 0, "Could not find a suitable fullscreen resolution");
|
DEBUG(driver, 0, "Could not find a suitable fullscreen resolution");
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int CDECL compare_res(const Dimension *pa, const Dimension *pb)
|
void SortResolutions()
|
||||||
{
|
{
|
||||||
int x = pa->width - pb->width;
|
std::sort(_resolutions.begin(), _resolutions.end());
|
||||||
if (x != 0) return x;
|
|
||||||
return pa->height - pb->height;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SortResolutions(int count)
|
|
||||||
{
|
|
||||||
QSortT(_resolutions, count, &compare_res);
|
|
||||||
}
|
}
|
||||||
|
@@ -66,8 +66,7 @@ extern bool _right_button_clicked;
|
|||||||
extern DrawPixelInfo _screen;
|
extern DrawPixelInfo _screen;
|
||||||
extern bool _screen_disable_anim; ///< Disable palette animation (important for 32bpp-anim blitter during giant screenshot)
|
extern bool _screen_disable_anim; ///< Disable palette animation (important for 32bpp-anim blitter during giant screenshot)
|
||||||
|
|
||||||
extern int _num_resolutions;
|
extern std::vector<Dimension> _resolutions;
|
||||||
extern Dimension _resolutions[32];
|
|
||||||
extern Dimension _cur_resolution;
|
extern Dimension _cur_resolution;
|
||||||
extern Palette _cur_palette; ///< Current palette
|
extern Palette _cur_palette; ///< Current palette
|
||||||
|
|
||||||
@@ -162,7 +161,7 @@ void SetAnimatedMouseCursor(const AnimCursor *table);
|
|||||||
void CursorTick();
|
void CursorTick();
|
||||||
void UpdateCursorSize();
|
void UpdateCursorSize();
|
||||||
bool ChangeResInGame(int w, int h);
|
bool ChangeResInGame(int w, int h);
|
||||||
void SortResolutions(int count);
|
void SortResolutions();
|
||||||
bool ToggleFullScreen(bool fs);
|
bool ToggleFullScreen(bool fs);
|
||||||
|
|
||||||
/* gfx.cpp */
|
/* gfx.cpp */
|
||||||
|
@@ -17,7 +17,6 @@
|
|||||||
#include "string_func.h"
|
#include "string_func.h"
|
||||||
#include "strings_func.h"
|
#include "strings_func.h"
|
||||||
#include "table/strings.h"
|
#include "table/strings.h"
|
||||||
#include "core/sort_func.hpp"
|
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
#include "safeguards.h"
|
#include "safeguards.h"
|
||||||
@@ -79,9 +78,9 @@ int8 SaveHighScoreValue(const Company *c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Sort all companies given their performance */
|
/** Sort all companies given their performance */
|
||||||
static int CDECL HighScoreSorter(const Company * const *a, const Company * const *b)
|
static bool HighScoreSorter(const Company * const &a, const Company * const &b)
|
||||||
{
|
{
|
||||||
return (*b)->old_economy[0].performance_history - (*a)->old_economy[0].performance_history;
|
return b->old_economy[0].performance_history < a->old_economy[0].performance_history;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -98,7 +97,7 @@ int8 SaveHighScoreValueNetwork()
|
|||||||
/* Sort all active companies with the highest score first */
|
/* Sort all active companies with the highest score first */
|
||||||
FOR_ALL_COMPANIES(c) cl[count++] = c;
|
FOR_ALL_COMPANIES(c) cl[count++] = c;
|
||||||
|
|
||||||
QSortT(cl, count, &HighScoreSorter);
|
std::sort(std::begin(cl), std::begin(cl) + count, HighScoreSorter);
|
||||||
|
|
||||||
{
|
{
|
||||||
uint i;
|
uint i;
|
||||||
|
@@ -183,23 +183,23 @@ static inline void GetAllCargoSuffixes(CargoSuffixInOut use_input, CargoSuffixTy
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IndustryType _sorted_industry_types[NUM_INDUSTRYTYPES]; ///< Industry types sorted by name.
|
std::array<IndustryType, NUM_INDUSTRYTYPES> _sorted_industry_types; ///< Industry types sorted by name.
|
||||||
|
|
||||||
/** Sort industry types by their name. */
|
/** Sort industry types by their name. */
|
||||||
static int CDECL IndustryTypeNameSorter(const IndustryType *a, const IndustryType *b)
|
static bool IndustryTypeNameSorter(const IndustryType &a, const IndustryType &b)
|
||||||
{
|
{
|
||||||
static char industry_name[2][64];
|
static char industry_name[2][64];
|
||||||
|
|
||||||
const IndustrySpec *indsp1 = GetIndustrySpec(*a);
|
const IndustrySpec *indsp1 = GetIndustrySpec(a);
|
||||||
GetString(industry_name[0], indsp1->name, lastof(industry_name[0]));
|
GetString(industry_name[0], indsp1->name, lastof(industry_name[0]));
|
||||||
|
|
||||||
const IndustrySpec *indsp2 = GetIndustrySpec(*b);
|
const IndustrySpec *indsp2 = GetIndustrySpec(b);
|
||||||
GetString(industry_name[1], indsp2->name, lastof(industry_name[1]));
|
GetString(industry_name[1], indsp2->name, lastof(industry_name[1]));
|
||||||
|
|
||||||
int r = strnatcmp(industry_name[0], industry_name[1]); // Sort by name (natural sorting).
|
int r = strnatcmp(industry_name[0], industry_name[1]); // Sort by name (natural sorting).
|
||||||
|
|
||||||
/* If the names are equal, sort by industry type. */
|
/* If the names are equal, sort by industry type. */
|
||||||
return (r != 0) ? r : (*a - *b);
|
return (r != 0) ? r < 0 : (a < b);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -213,7 +213,7 @@ void SortIndustryTypes()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Sort industry types by name. */
|
/* Sort industry types by name. */
|
||||||
QSortT(_sorted_industry_types, NUM_INDUSTRYTYPES, &IndustryTypeNameSorter);
|
std::sort(_sorted_industry_types.begin(), _sorted_industry_types.end(), IndustryTypeNameSorter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -302,8 +302,7 @@ class BuildIndustryWindow : public Window {
|
|||||||
* The tests performed after the enabled allow to load the industries
|
* The tests performed after the enabled allow to load the industries
|
||||||
* In the same way they are inserted by grf (if any)
|
* In the same way they are inserted by grf (if any)
|
||||||
*/
|
*/
|
||||||
for (uint i = 0; i < NUM_INDUSTRYTYPES; i++) {
|
for (IndustryType ind : _sorted_industry_types) {
|
||||||
IndustryType ind = _sorted_industry_types[i];
|
|
||||||
const IndustrySpec *indsp = GetIndustrySpec(ind);
|
const IndustrySpec *indsp = GetIndustrySpec(ind);
|
||||||
if (indsp->enabled) {
|
if (indsp->enabled) {
|
||||||
/* Rule is that editor mode loads all industries.
|
/* Rule is that editor mode loads all industries.
|
||||||
@@ -2731,8 +2730,7 @@ struct IndustryCargoesWindow : public Window {
|
|||||||
|
|
||||||
case WID_IC_IND_DROPDOWN: {
|
case WID_IC_IND_DROPDOWN: {
|
||||||
DropDownList lst;
|
DropDownList lst;
|
||||||
for (uint i = 0; i < NUM_INDUSTRYTYPES; i++) {
|
for (IndustryType ind : _sorted_industry_types) {
|
||||||
IndustryType ind = _sorted_industry_types[i];
|
|
||||||
const IndustrySpec *indsp = GetIndustrySpec(ind);
|
const IndustrySpec *indsp = GetIndustrySpec(ind);
|
||||||
if (!indsp->enabled) continue;
|
if (!indsp->enabled) continue;
|
||||||
lst.emplace_back(new DropDownListStringItem(indsp->name, ind, false));
|
lst.emplace_back(new DropDownListStringItem(indsp->name, ind, false));
|
||||||
@@ -2819,10 +2817,10 @@ const int IndustryCargoesWindow::VERT_TEXT_PADDING = 5; ///< Vertical padding ar
|
|||||||
static void ShowIndustryCargoesWindow(IndustryType id)
|
static void ShowIndustryCargoesWindow(IndustryType id)
|
||||||
{
|
{
|
||||||
if (id >= NUM_INDUSTRYTYPES) {
|
if (id >= NUM_INDUSTRYTYPES) {
|
||||||
for (uint i = 0; i < NUM_INDUSTRYTYPES; i++) {
|
for (IndustryType ind : _sorted_industry_types) {
|
||||||
const IndustrySpec *indsp = GetIndustrySpec(_sorted_industry_types[i]);
|
const IndustrySpec *indsp = GetIndustrySpec(ind);
|
||||||
if (indsp->enabled) {
|
if (indsp->enabled) {
|
||||||
id = _sorted_industry_types[i];
|
id = ind;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
#ifndef INDUSTRYTYPE_H
|
#ifndef INDUSTRYTYPE_H
|
||||||
#define INDUSTRYTYPE_H
|
#define INDUSTRYTYPE_H
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include "map_type.h"
|
#include "map_type.h"
|
||||||
#include "slope_type.h"
|
#include "slope_type.h"
|
||||||
#include "industry_type.h"
|
#include "industry_type.h"
|
||||||
@@ -179,7 +180,7 @@ extern IndustryTileSpec _industry_tile_specs[NUM_INDUSTRYTILES];
|
|||||||
/* industry_gui.cpp */
|
/* industry_gui.cpp */
|
||||||
void SortIndustryTypes();
|
void SortIndustryTypes();
|
||||||
/* Industry types sorted alphabetically by name. */
|
/* Industry types sorted alphabetically by name. */
|
||||||
extern IndustryType _sorted_industry_types[NUM_INDUSTRYTYPES];
|
extern std::array<IndustryType, NUM_INDUSTRYTYPES> _sorted_industry_types;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do industry gfx ID translation for NewGRFs.
|
* Do industry gfx ID translation for NewGRFs.
|
||||||
|
@@ -464,6 +464,7 @@ STR_TOOLBAR_SOUND_MUSIC :Suara/musik
|
|||||||
############ range for message menu starts
|
############ range for message menu starts
|
||||||
STR_NEWS_MENU_LAST_MESSAGE_NEWS_REPORT :Pesan/Berita terakhir
|
STR_NEWS_MENU_LAST_MESSAGE_NEWS_REPORT :Pesan/Berita terakhir
|
||||||
STR_NEWS_MENU_MESSAGE_HISTORY_MENU :Berita Lampau
|
STR_NEWS_MENU_MESSAGE_HISTORY_MENU :Berita Lampau
|
||||||
|
STR_NEWS_MENU_DELETE_ALL_MESSAGES :Hapus semua pesan
|
||||||
############ range ends here
|
############ range ends here
|
||||||
|
|
||||||
############ range for about menu starts
|
############ range for about menu starts
|
||||||
@@ -989,7 +990,10 @@ STR_GAME_OPTIONS_GUI_ZOOM_DROPDOWN_NORMAL :Normal
|
|||||||
STR_GAME_OPTIONS_GUI_ZOOM_DROPDOWN_2X_ZOOM :Kali dua
|
STR_GAME_OPTIONS_GUI_ZOOM_DROPDOWN_2X_ZOOM :Kali dua
|
||||||
STR_GAME_OPTIONS_GUI_ZOOM_DROPDOWN_4X_ZOOM :Kali empat
|
STR_GAME_OPTIONS_GUI_ZOOM_DROPDOWN_4X_ZOOM :Kali empat
|
||||||
|
|
||||||
|
STR_GAME_OPTIONS_FONT_ZOOM :{BLACK}Ukuran font
|
||||||
|
|
||||||
|
STR_GAME_OPTIONS_FONT_ZOOM_DROPDOWN_NORMAL :Normal
|
||||||
|
STR_GAME_OPTIONS_FONT_ZOOM_DROPDOWN_4X_ZOOM :4 kali
|
||||||
|
|
||||||
STR_GAME_OPTIONS_BASE_GRF :{BLACK}Set Grafik Dasar
|
STR_GAME_OPTIONS_BASE_GRF :{BLACK}Set Grafik Dasar
|
||||||
STR_GAME_OPTIONS_BASE_GRF_TOOLTIP :{BLACK}Pilih grafik dasar yang digunakan
|
STR_GAME_OPTIONS_BASE_GRF_TOOLTIP :{BLACK}Pilih grafik dasar yang digunakan
|
||||||
@@ -1221,7 +1225,7 @@ STR_CONFIG_SETTING_NONSTOP_BY_DEFAULT :Tujuan baru sta
|
|||||||
STR_CONFIG_SETTING_NONSTOP_BY_DEFAULT_HELPTEXT :Biasanya, kendaraan akan berhenti di setiap stasiun yang di lewati. Dengan mengaktifkan pengaturan ini, maka kendaraan akan melewati semua stasiun dalam perjalanan ke tujuan akhir. Perhatikan, bahwa pengaturan ini hanya mendefinisikan nilai default. Perintah individu dapat diatur
|
STR_CONFIG_SETTING_NONSTOP_BY_DEFAULT_HELPTEXT :Biasanya, kendaraan akan berhenti di setiap stasiun yang di lewati. Dengan mengaktifkan pengaturan ini, maka kendaraan akan melewati semua stasiun dalam perjalanan ke tujuan akhir. Perhatikan, bahwa pengaturan ini hanya mendefinisikan nilai default. Perintah individu dapat diatur
|
||||||
STR_CONFIG_SETTING_STOP_LOCATION :Order kereta yang baru aslinya berhenti {STRING} dari stasiun
|
STR_CONFIG_SETTING_STOP_LOCATION :Order kereta yang baru aslinya berhenti {STRING} dari stasiun
|
||||||
STR_CONFIG_SETTING_STOP_LOCATION_HELPTEXT :Tempat kereta akan berhenti di peron stasiun. 'Dekat akhir' berarti dekat dengan titik masuk, 'tengah' berarti di tengah-tengah peron, dan 'jauh dari akhir' berarti jauh dari titik masuk
|
STR_CONFIG_SETTING_STOP_LOCATION_HELPTEXT :Tempat kereta akan berhenti di peron stasiun. 'Dekat akhir' berarti dekat dengan titik masuk, 'tengah' berarti di tengah-tengah peron, dan 'jauh dari akhir' berarti jauh dari titik masuk
|
||||||
STR_CONFIG_SETTING_STOP_LOCATION_NEAR_END :hampir selesai
|
STR_CONFIG_SETTING_STOP_LOCATION_NEAR_END :tepi terdekat
|
||||||
STR_CONFIG_SETTING_STOP_LOCATION_MIDDLE :tengah
|
STR_CONFIG_SETTING_STOP_LOCATION_MIDDLE :tengah
|
||||||
STR_CONFIG_SETTING_STOP_LOCATION_FAR_END :jauh di belakang
|
STR_CONFIG_SETTING_STOP_LOCATION_FAR_END :jauh di belakang
|
||||||
STR_CONFIG_SETTING_AUTOSCROLL :Geser tampilan saat mouse ada di tepi: {STRING}
|
STR_CONFIG_SETTING_AUTOSCROLL :Geser tampilan saat mouse ada di tepi: {STRING}
|
||||||
@@ -1258,6 +1262,7 @@ STR_CONFIG_SETTING_DYNAMIC_ENGINES_EXISTING_VEHICLES :{WHITE}Tidak di
|
|||||||
STR_CONFIG_SETTING_INFRASTRUCTURE_MAINTENANCE :Pemeliharaan Infrastruktur: {STRING}
|
STR_CONFIG_SETTING_INFRASTRUCTURE_MAINTENANCE :Pemeliharaan Infrastruktur: {STRING}
|
||||||
STR_CONFIG_SETTING_INFRASTRUCTURE_MAINTENANCE_HELPTEXT :Jika dinyalakan, infrastruktur membutuhkan biaya pemeliharaan. Biaya berkembang secara proporsional sesuai dengan ukuran jaringan, lebih berdampak pada perusahaan besar dari pada perusahaan kecil
|
STR_CONFIG_SETTING_INFRASTRUCTURE_MAINTENANCE_HELPTEXT :Jika dinyalakan, infrastruktur membutuhkan biaya pemeliharaan. Biaya berkembang secara proporsional sesuai dengan ukuran jaringan, lebih berdampak pada perusahaan besar dari pada perusahaan kecil
|
||||||
|
|
||||||
|
STR_CONFIG_SETTING_COMPANY_STARTING_COLOUR_HELPTEXT :Pilih warna awal perusahaan
|
||||||
|
|
||||||
STR_CONFIG_SETTING_NEVER_EXPIRE_AIRPORTS :Bandara tidak kedaluarsa: {STRING}
|
STR_CONFIG_SETTING_NEVER_EXPIRE_AIRPORTS :Bandara tidak kedaluarsa: {STRING}
|
||||||
STR_CONFIG_SETTING_NEVER_EXPIRE_AIRPORTS_HELPTEXT :Menyalakan setelan ini membuat semua jenis bandara tetap ada selamanya sejak pendesainanya
|
STR_CONFIG_SETTING_NEVER_EXPIRE_AIRPORTS_HELPTEXT :Menyalakan setelan ini membuat semua jenis bandara tetap ada selamanya sejak pendesainanya
|
||||||
@@ -1567,6 +1572,7 @@ STR_CONFIG_SETTING_TOWN_FOUNDING_HELPTEXT :Mengaktifkan se
|
|||||||
STR_CONFIG_SETTING_TOWN_FOUNDING_FORBIDDEN :Dilarang
|
STR_CONFIG_SETTING_TOWN_FOUNDING_FORBIDDEN :Dilarang
|
||||||
STR_CONFIG_SETTING_TOWN_FOUNDING_ALLOWED :Diijinkan
|
STR_CONFIG_SETTING_TOWN_FOUNDING_ALLOWED :Diijinkan
|
||||||
STR_CONFIG_SETTING_TOWN_FOUNDING_ALLOWED_CUSTOM_LAYOUT :Diijinkan, layout kota sendiri
|
STR_CONFIG_SETTING_TOWN_FOUNDING_ALLOWED_CUSTOM_LAYOUT :Diijinkan, layout kota sendiri
|
||||||
|
STR_CONFIG_SETTING_TOWN_CARGOGENMODE_BITCOUNT :Linier
|
||||||
|
|
||||||
STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT :Penempatan pohon dalam permainan: {STRING}
|
STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT :Penempatan pohon dalam permainan: {STRING}
|
||||||
STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_HELPTEXT :Mengendalikan kemunculan pohon dalam permainan. Ini akan berefek pada industri yang memerlukan pohon, contohnya pengolahan kayu gelondongan
|
STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_HELPTEXT :Mengendalikan kemunculan pohon dalam permainan. Ini akan berefek pada industri yang memerlukan pohon, contohnya pengolahan kayu gelondongan
|
||||||
@@ -1807,6 +1813,7 @@ STR_CHEAT_CHANGE_DATE_QUERY_CAPT :{WHITE}Ubah tah
|
|||||||
STR_CHEAT_SETUP_PROD :{LTBLUE}Aktifkan modifikasi nilai produksi: {ORANGE}{STRING}
|
STR_CHEAT_SETUP_PROD :{LTBLUE}Aktifkan modifikasi nilai produksi: {ORANGE}{STRING}
|
||||||
|
|
||||||
# Livery window
|
# Livery window
|
||||||
|
STR_LIVERY_CAPTION :{WHITE}{COMPANY} - Skema Warna
|
||||||
|
|
||||||
STR_LIVERY_GENERAL_TOOLTIP :{BLACK}Tampilkan skema warna umum
|
STR_LIVERY_GENERAL_TOOLTIP :{BLACK}Tampilkan skema warna umum
|
||||||
STR_LIVERY_TRAIN_TOOLTIP :{BLACK}Tampilkan skema warna kereta
|
STR_LIVERY_TRAIN_TOOLTIP :{BLACK}Tampilkan skema warna kereta
|
||||||
@@ -2690,6 +2697,7 @@ STR_ABOUT_COPYRIGHT_OPENTTD :{BLACK}OpenTTD
|
|||||||
# Framerate display window
|
# Framerate display window
|
||||||
STR_FRAMERATE_CAPTION_SMALL :{STRING}{WHITE} ({DECIMAL}x)
|
STR_FRAMERATE_CAPTION_SMALL :{STRING}{WHITE} ({DECIMAL}x)
|
||||||
STR_FRAMERATE_RATE_GAMELOOP :{WHITE}Rata simulasi: {STRING}
|
STR_FRAMERATE_RATE_GAMELOOP :{WHITE}Rata simulasi: {STRING}
|
||||||
|
STR_FRAMERATE_RATE_GAMELOOP_TOOLTIP :{BLACK}Jumlah detak permainan tersimulasi per detik.
|
||||||
STR_FRAMERATE_SPEED_FACTOR_TOOLTIP :{BLACK}Beberapa cepat permainan lagi berjalan, dibanding dengan kecepatan diharapkan memakai rata simulasi biasa.
|
STR_FRAMERATE_SPEED_FACTOR_TOOLTIP :{BLACK}Beberapa cepat permainan lagi berjalan, dibanding dengan kecepatan diharapkan memakai rata simulasi biasa.
|
||||||
STR_FRAMERATE_CURRENT :{WHITE}Sekarang
|
STR_FRAMERATE_CURRENT :{WHITE}Sekarang
|
||||||
STR_FRAMERATE_DATA_POINTS :{WHITE}Data tergantung oleh ukuran {COMMA}
|
STR_FRAMERATE_DATA_POINTS :{WHITE}Data tergantung oleh ukuran {COMMA}
|
||||||
@@ -2706,6 +2714,7 @@ STR_FRAMERATE_GL_SHIPS :{WHITE} Titik k
|
|||||||
STR_FRAMERATE_GL_AIRCRAFT :{WHITE} Titik pesawat:
|
STR_FRAMERATE_GL_AIRCRAFT :{WHITE} Titik pesawat:
|
||||||
STR_FRAMERATE_GL_LANDSCAPE :{WHITE} Titik dunia:
|
STR_FRAMERATE_GL_LANDSCAPE :{WHITE} Titik dunia:
|
||||||
STR_FRAMERATE_DRAWING_VIEWPORTS :{WHITE} Viewport dunia:
|
STR_FRAMERATE_DRAWING_VIEWPORTS :{WHITE} Viewport dunia:
|
||||||
|
STR_FRAMERATE_VIDEO :{BLACK}Keluaran Video:
|
||||||
STR_FRAMERATE_SOUND :{WHITE}Mixing suara:
|
STR_FRAMERATE_SOUND :{WHITE}Mixing suara:
|
||||||
############ End of leave-in-this-order
|
############ End of leave-in-this-order
|
||||||
############ Leave those lines in this order!!
|
############ Leave those lines in this order!!
|
||||||
@@ -2716,6 +2725,7 @@ STR_FRAMETIME_CAPTION_GL_SHIPS :Titik kapal
|
|||||||
STR_FRAMETIME_CAPTION_GL_AIRCRAFT :Titik pesawat
|
STR_FRAMETIME_CAPTION_GL_AIRCRAFT :Titik pesawat
|
||||||
STR_FRAMETIME_CAPTION_GL_LANDSCAPE :Titik dunia
|
STR_FRAMETIME_CAPTION_GL_LANDSCAPE :Titik dunia
|
||||||
STR_FRAMETIME_CAPTION_SOUND :Mixing suara
|
STR_FRAMETIME_CAPTION_SOUND :Mixing suara
|
||||||
|
STR_FRAMETIME_CAPTION_AI :AI {NUM} {STRING}
|
||||||
############ End of leave-in-this-order
|
############ End of leave-in-this-order
|
||||||
|
|
||||||
|
|
||||||
@@ -2905,6 +2915,7 @@ STR_SPRITE_ALIGNER_PREVIOUS_BUTTON :{BLACK}Sprite s
|
|||||||
STR_SPRITE_ALIGNER_PREVIOUS_TOOLTIP :{BLACK}Lanjutkan ke sprite normal sebelumnya, lewati sembarang sprite bayangan/warna ulang/huruf dan pembungkus saat mulai
|
STR_SPRITE_ALIGNER_PREVIOUS_TOOLTIP :{BLACK}Lanjutkan ke sprite normal sebelumnya, lewati sembarang sprite bayangan/warna ulang/huruf dan pembungkus saat mulai
|
||||||
STR_SPRITE_ALIGNER_SPRITE_TOOLTIP :{BLACK}Mewakili sprite yang sedang dipilih. Penjajaran diabaikan ketika sprite ini digambar
|
STR_SPRITE_ALIGNER_SPRITE_TOOLTIP :{BLACK}Mewakili sprite yang sedang dipilih. Penjajaran diabaikan ketika sprite ini digambar
|
||||||
STR_SPRITE_ALIGNER_MOVE_TOOLTIP :{BLACK}Pindahkan sprite, mengubah offset X dan Y
|
STR_SPRITE_ALIGNER_MOVE_TOOLTIP :{BLACK}Pindahkan sprite, mengubah offset X dan Y
|
||||||
|
STR_SPRITE_ALIGNER_RESET_BUTTON :{BLACK}Reset relatif
|
||||||
STR_SPRITE_ALIGNER_PICKER_BUTTON :{BLACK}Pilih sprite
|
STR_SPRITE_ALIGNER_PICKER_BUTTON :{BLACK}Pilih sprite
|
||||||
STR_SPRITE_ALIGNER_PICKER_TOOLTIP :{BLACK}Pilih sebuah sprite di manapun pada layar
|
STR_SPRITE_ALIGNER_PICKER_TOOLTIP :{BLACK}Pilih sebuah sprite di manapun pada layar
|
||||||
|
|
||||||
@@ -3409,6 +3420,7 @@ STR_PURCHASE_INFO_RELIABILITY :{BLACK}Kehandal
|
|||||||
STR_PURCHASE_INFO_COST :{BLACK}Biaya: {GOLD}{CURRENCY_LONG}
|
STR_PURCHASE_INFO_COST :{BLACK}Biaya: {GOLD}{CURRENCY_LONG}
|
||||||
STR_PURCHASE_INFO_WEIGHT_CWEIGHT :{BLACK}Berat: {GOLD}{WEIGHT_SHORT} ({WEIGHT_SHORT})
|
STR_PURCHASE_INFO_WEIGHT_CWEIGHT :{BLACK}Berat: {GOLD}{WEIGHT_SHORT} ({WEIGHT_SHORT})
|
||||||
STR_PURCHASE_INFO_COST_SPEED :{BLACK}Biaya: {GOLD}{CURRENCY_LONG}{BLACK} Kecepatan: {GOLD}{VELOCITY}
|
STR_PURCHASE_INFO_COST_SPEED :{BLACK}Biaya: {GOLD}{CURRENCY_LONG}{BLACK} Kecepatan: {GOLD}{VELOCITY}
|
||||||
|
STR_PURCHASE_INFO_COST_REFIT_SPEED :{BLACK}Biaya: {GOLD}{CURRENCY_LONG}{BLACK} (Biaya Karoseri: {GOLD}{CURRENCY_LONG}{BLACK}) Kecepatan: {GOLD}{VELOCITY}
|
||||||
STR_PURCHASE_INFO_AIRCRAFT_CAPACITY :{BLACK}Daya Muat: {GOLD}{CARGO_LONG}, {CARGO_LONG}
|
STR_PURCHASE_INFO_AIRCRAFT_CAPACITY :{BLACK}Daya Muat: {GOLD}{CARGO_LONG}, {CARGO_LONG}
|
||||||
STR_PURCHASE_INFO_PWAGPOWER_PWAGWEIGHT :{BLACK}Daya Gerbong: {GOLD}+{POWER}{BLACK} Berat: {GOLD}+{WEIGHT_SHORT}
|
STR_PURCHASE_INFO_PWAGPOWER_PWAGWEIGHT :{BLACK}Daya Gerbong: {GOLD}+{POWER}{BLACK} Berat: {GOLD}+{WEIGHT_SHORT}
|
||||||
STR_PURCHASE_INFO_REFITTABLE_TO :{BLACK}Kargo dapat di ganti untuk: {GOLD}{STRING}
|
STR_PURCHASE_INFO_REFITTABLE_TO :{BLACK}Kargo dapat di ganti untuk: {GOLD}{STRING}
|
||||||
@@ -3434,6 +3446,8 @@ STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_VEHICLE_TOOLTIP :{BLACK}Beli ken
|
|||||||
STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Beli kapal yang dipilih. Shift untuk menampilkan perkiraan biaya
|
STR_BUY_VEHICLE_SHIP_BUY_VEHICLE_TOOLTIP :{BLACK}Beli kapal yang dipilih. Shift untuk menampilkan perkiraan biaya
|
||||||
STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Beli pesawat yang dipilih. Shift untuk menampilkan perkiraan biaya
|
STR_BUY_VEHICLE_AIRCRAFT_BUY_VEHICLE_TOOLTIP :{BLACK}Beli pesawat yang dipilih. Shift untuk menampilkan perkiraan biaya
|
||||||
|
|
||||||
|
STR_BUY_VEHICLE_ROAD_VEHICLE_BUY_REFIT_VEHICLE_TOOLTIP :{BLACK}Beli lalu karoseri kendaraan yang dipilih. Shift+Klik untuk menampilkan perkiraan biaya tanpa membelinya
|
||||||
|
STR_BUY_VEHICLE_SHIP_BUY_REFIT_VEHICLE_TOOLTIP :{BLACK}Beli lalu karoseri kapal yang dipilih. Shift+Klik untuk menampilkan perkiraan biaya tanpa membelinya
|
||||||
|
|
||||||
STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Ubah Nama
|
STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON :{BLACK}Ubah Nama
|
||||||
STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Ganti Nama
|
STR_BUY_VEHICLE_ROAD_VEHICLE_RENAME_BUTTON :{BLACK}Ganti Nama
|
||||||
|
@@ -65,18 +65,18 @@ static const StringID _lan_internet_types_dropdown[] = {
|
|||||||
INVALID_STRING_ID
|
INVALID_STRING_ID
|
||||||
};
|
};
|
||||||
|
|
||||||
static StringID _language_dropdown[NETLANG_COUNT + 1] = {STR_NULL};
|
static std::vector<StringID> _language_dropdown;
|
||||||
|
|
||||||
void SortNetworkLanguages()
|
void SortNetworkLanguages()
|
||||||
{
|
{
|
||||||
/* Init the strings */
|
/* Init the strings */
|
||||||
if (_language_dropdown[0] == STR_NULL) {
|
if (_language_dropdown.empty()) {
|
||||||
for (int i = 0; i < NETLANG_COUNT; i++) _language_dropdown[i] = STR_NETWORK_LANG_ANY + i;
|
for (int i = 0; i < NETLANG_COUNT; i++) _language_dropdown.emplace_back(STR_NETWORK_LANG_ANY + i);
|
||||||
_language_dropdown[NETLANG_COUNT] = INVALID_STRING_ID;
|
_language_dropdown.emplace_back(INVALID_STRING_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sort the strings (we don't move 'any' and the 'invalid' one) */
|
/* Sort the strings (we don't move 'any' and the 'invalid' one) */
|
||||||
QSortT(_language_dropdown + 1, NETLANG_COUNT - 1, &StringIDSorter);
|
std::sort(_language_dropdown.begin() + 1, _language_dropdown.end() - 1, StringIDSorter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1174,13 +1174,13 @@ struct NetworkStartServerWindow : public Window {
|
|||||||
|
|
||||||
case WID_NSS_LANGUAGE_BTN: { // Language
|
case WID_NSS_LANGUAGE_BTN: { // Language
|
||||||
uint sel = 0;
|
uint sel = 0;
|
||||||
for (uint i = 0; i < lengthof(_language_dropdown) - 1; i++) {
|
for (uint i = 0; i < _language_dropdown.size() - 1; i++) {
|
||||||
if (_language_dropdown[i] == STR_NETWORK_LANG_ANY + _settings_client.network.server_lang) {
|
if (_language_dropdown[i] == STR_NETWORK_LANG_ANY + _settings_client.network.server_lang) {
|
||||||
sel = i;
|
sel = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ShowDropDownMenu(this, _language_dropdown, sel, WID_NSS_LANGUAGE_BTN, 0, 0);
|
ShowDropDownMenu(this, _language_dropdown.data(), sel, WID_NSS_LANGUAGE_BTN, 0, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -5585,7 +5585,8 @@ static void RailTypeMapSpriteGroup(ByteReader *buf, uint8 idcount)
|
|||||||
{
|
{
|
||||||
uint8 *railtypes = AllocaM(uint8, idcount);
|
uint8 *railtypes = AllocaM(uint8, idcount);
|
||||||
for (uint i = 0; i < idcount; i++) {
|
for (uint i = 0; i < idcount; i++) {
|
||||||
railtypes[i] = _cur.grffile->railtype_map[buf->ReadByte()];
|
uint8 id = buf->ReadByte();
|
||||||
|
railtypes[i] = id < RAILTYPE_END ? _cur.grffile->railtype_map[id] : INVALID_RAILTYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8 cidcount = buf->ReadByte();
|
uint8 cidcount = buf->ReadByte();
|
||||||
|
@@ -711,16 +711,13 @@ bool GRFFileScanner::AddFile(const char *filename, size_t basepath_length, const
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple sorter for GRFS
|
* Simple sorter for GRFS
|
||||||
* @param p1 the first GRFConfig *
|
* @param c1 the first GRFConfig *
|
||||||
* @param p2 the second GRFConfig *
|
* @param c2 the second GRFConfig *
|
||||||
* @return the same strcmp would return for the name of the NewGRF.
|
* @return true if the name of first NewGRF is before the name of the second.
|
||||||
*/
|
*/
|
||||||
static int CDECL GRFSorter(GRFConfig * const *p1, GRFConfig * const *p2)
|
static bool GRFSorter(GRFConfig * const &c1, GRFConfig * const &c2)
|
||||||
{
|
{
|
||||||
const GRFConfig *c1 = *p1;
|
return strnatcmp(c1->GetName(), c2->GetName()) < 0;
|
||||||
const GRFConfig *c2 = *p2;
|
|
||||||
|
|
||||||
return strnatcmp(c1->GetName(), c2->GetName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -742,16 +739,16 @@ void DoScanNewGRFFiles(NewGRFScanCallback *callback)
|
|||||||
/* Sort the linked list using quicksort.
|
/* Sort the linked list using quicksort.
|
||||||
* For that we first have to make an array, then sort and
|
* For that we first have to make an array, then sort and
|
||||||
* then remake the linked list. */
|
* then remake the linked list. */
|
||||||
GRFConfig **to_sort = MallocT<GRFConfig*>(num);
|
std::vector<GRFConfig *> to_sort;
|
||||||
|
|
||||||
uint i = 0;
|
uint i = 0;
|
||||||
for (GRFConfig *p = _all_grfs; p != nullptr; p = p->next, i++) {
|
for (GRFConfig *p = _all_grfs; p != nullptr; p = p->next, i++) {
|
||||||
to_sort[i] = p;
|
to_sort.push_back(p);
|
||||||
}
|
}
|
||||||
/* Number of files is not necessarily right */
|
/* Number of files is not necessarily right */
|
||||||
num = i;
|
num = i;
|
||||||
|
|
||||||
QSortT(to_sort, num, &GRFSorter);
|
std::sort(to_sort.begin(), to_sort.end(), GRFSorter);
|
||||||
|
|
||||||
for (i = 1; i < num; i++) {
|
for (i = 1; i < num; i++) {
|
||||||
to_sort[i - 1]->next = to_sort[i];
|
to_sort[i - 1]->next = to_sort[i];
|
||||||
@@ -759,8 +756,6 @@ void DoScanNewGRFFiles(NewGRFScanCallback *callback)
|
|||||||
to_sort[num - 1]->next = nullptr;
|
to_sort[num - 1]->next = nullptr;
|
||||||
_all_grfs = to_sort[0];
|
_all_grfs = to_sort[0];
|
||||||
|
|
||||||
free(to_sort);
|
|
||||||
|
|
||||||
NetworkAfterNewGRFScan();
|
NetworkAfterNewGRFScan();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -532,6 +532,9 @@ char *TranslateTTDPatchCodes(uint32 grfid, uint8 language_id, bool allow_newline
|
|||||||
d += Utf8Encode(d, SCC_NEWGRF_PRINT_DWORD_DATE_LONG + code - 0x16);
|
d += Utf8Encode(d, SCC_NEWGRF_PRINT_DWORD_DATE_LONG + code - 0x16);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 0x1F: d += Utf8Encode(d, SCC_PUSH_COLOUR); break;
|
||||||
|
case 0x20: d += Utf8Encode(d, SCC_POP_COLOUR); break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
grfmsg(1, "missing handler for extended format code");
|
grfmsg(1, "missing handler for extended format code");
|
||||||
break;
|
break;
|
||||||
|
@@ -464,15 +464,14 @@ void ResetRailTypes();
|
|||||||
void InitRailTypes();
|
void InitRailTypes();
|
||||||
RailType AllocateRailType(RailTypeLabel label);
|
RailType AllocateRailType(RailTypeLabel label);
|
||||||
|
|
||||||
extern RailType _sorted_railtypes[RAILTYPE_END];
|
extern std::vector<RailType> _sorted_railtypes;
|
||||||
extern uint8 _sorted_railtypes_size;
|
|
||||||
extern RailTypes _railtypes_hidden_mask;
|
extern RailTypes _railtypes_hidden_mask;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loop header for iterating over railtypes, sorted by sortorder.
|
* Loop header for iterating over railtypes, sorted by sortorder.
|
||||||
* @param var Railtype.
|
* @param var Railtype.
|
||||||
*/
|
*/
|
||||||
#define FOR_ALL_SORTED_RAILTYPES(var) for (uint8 index = 0; index < _sorted_railtypes_size && (var = _sorted_railtypes[index], true) ; index++)
|
#define FOR_ALL_SORTED_RAILTYPES(var) for (uint8 index = 0; index < _sorted_railtypes.size() && (var = _sorted_railtypes[index], true) ; index++)
|
||||||
|
|
||||||
/** Enum holding the signal offset in the sprite sheet according to the side it is representing. */
|
/** Enum holding the signal offset in the sprite sheet according to the side it is representing. */
|
||||||
enum SignalOffsets {
|
enum SignalOffsets {
|
||||||
|
@@ -52,8 +52,7 @@
|
|||||||
typedef std::vector<Train *> TrainList;
|
typedef std::vector<Train *> TrainList;
|
||||||
|
|
||||||
RailtypeInfo _railtypes[RAILTYPE_END];
|
RailtypeInfo _railtypes[RAILTYPE_END];
|
||||||
RailType _sorted_railtypes[RAILTYPE_END];
|
std::vector<RailType> _sorted_railtypes;
|
||||||
uint8 _sorted_railtypes_size;
|
|
||||||
TileIndex _rail_track_endtile; ///< The end of a rail track; as hidden return from the rail build/remove command for GUI purposes.
|
TileIndex _rail_track_endtile; ///< The end of a rail track; as hidden return from the rail build/remove command for GUI purposes.
|
||||||
RailTypes _railtypes_hidden_mask;
|
RailTypes _railtypes_hidden_mask;
|
||||||
|
|
||||||
@@ -129,9 +128,9 @@ void ResolveRailTypeGUISprites(RailtypeInfo *rti)
|
|||||||
* @param second The railtype to compare.
|
* @param second The railtype to compare.
|
||||||
* @return True iff the first should be sorted before the second.
|
* @return True iff the first should be sorted before the second.
|
||||||
*/
|
*/
|
||||||
static int CDECL CompareRailTypes(const RailType *first, const RailType *second)
|
static bool CompareRailTypes(const RailType &first, const RailType &second)
|
||||||
{
|
{
|
||||||
return GetRailTypeInfo(*first)->sorting_order - GetRailTypeInfo(*second)->sorting_order;
|
return GetRailTypeInfo(first)->sorting_order < GetRailTypeInfo(second)->sorting_order;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -145,13 +144,13 @@ void InitRailTypes()
|
|||||||
if (HasBit(rti->flags, RTF_HIDDEN)) SetBit(_railtypes_hidden_mask, rt);
|
if (HasBit(rti->flags, RTF_HIDDEN)) SetBit(_railtypes_hidden_mask, rt);
|
||||||
}
|
}
|
||||||
|
|
||||||
_sorted_railtypes_size = 0;
|
_sorted_railtypes.clear();
|
||||||
for (RailType rt = RAILTYPE_BEGIN; rt != RAILTYPE_END; rt++) {
|
for (RailType rt = RAILTYPE_BEGIN; rt != RAILTYPE_END; rt++) {
|
||||||
if (_railtypes[rt].label != 0 && !HasBit(_railtypes_hidden_mask, rt)) {
|
if (_railtypes[rt].label != 0 && !HasBit(_railtypes_hidden_mask, rt)) {
|
||||||
_sorted_railtypes[_sorted_railtypes_size++] = rt;
|
_sorted_railtypes.push_back(rt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QSortT(_sorted_railtypes, _sorted_railtypes_size, CompareRailTypes);
|
std::sort(_sorted_railtypes.begin(), _sorted_railtypes.end(), CompareRailTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -19,7 +19,6 @@
|
|||||||
#include "settings_type.h"
|
#include "settings_type.h"
|
||||||
#include "cmd_helper.h"
|
#include "cmd_helper.h"
|
||||||
#include "company_base.h"
|
#include "company_base.h"
|
||||||
#include "core/sort_func.hpp"
|
|
||||||
#include "settings_type.h"
|
#include "settings_type.h"
|
||||||
#include "schdispatch.h"
|
#include "schdispatch.h"
|
||||||
#include "vehicle_gui.h"
|
#include "vehicle_gui.h"
|
||||||
|
@@ -104,17 +104,14 @@ static inline StringID TownName(int town_name)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get index of the current screen resolution.
|
* Get index of the current screen resolution.
|
||||||
* @return Index of the current screen resolution if it is a known resolution, #_num_resolutions otherwise.
|
* @return Index of the current screen resolution if it is a known resolution, _resolutions.size() otherwise.
|
||||||
*/
|
*/
|
||||||
static int GetCurRes()
|
static uint GetCurRes()
|
||||||
{
|
{
|
||||||
int i;
|
uint i;
|
||||||
|
|
||||||
for (i = 0; i != _num_resolutions; i++) {
|
for (i = 0; i != _resolutions.size(); i++) {
|
||||||
if ((int)_resolutions[i].width == _screen.width &&
|
if (_resolutions[i] == Dimension(_screen.width, _screen.height)) break;
|
||||||
(int)_resolutions[i].height == _screen.height) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@@ -286,10 +283,10 @@ struct GameOptionsWindow : Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case WID_GO_RESOLUTION_DROPDOWN: // Setup resolution dropdown
|
case WID_GO_RESOLUTION_DROPDOWN: // Setup resolution dropdown
|
||||||
if (_num_resolutions == 0) break;
|
if (_resolutions.empty()) break;
|
||||||
|
|
||||||
*selected_index = GetCurRes();
|
*selected_index = GetCurRes();
|
||||||
for (int i = 0; i < _num_resolutions; i++) {
|
for (uint i = 0; i < _resolutions.size(); i++) {
|
||||||
list.emplace_back(new DropDownListStringItem(SPECSTR_RESOLUTION_START + i, i, false));
|
list.emplace_back(new DropDownListStringItem(SPECSTR_RESOLUTION_START + i, i, false));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -336,7 +333,7 @@ struct GameOptionsWindow : Window {
|
|||||||
case WID_GO_TOWNNAME_DROPDOWN: SetDParam(0, TownName(this->opt->game_creation.town_name)); break;
|
case WID_GO_TOWNNAME_DROPDOWN: SetDParam(0, TownName(this->opt->game_creation.town_name)); break;
|
||||||
case WID_GO_AUTOSAVE_DROPDOWN: SetDParam(0, _autosave_dropdown[_settings_client.gui.autosave]); break;
|
case WID_GO_AUTOSAVE_DROPDOWN: SetDParam(0, _autosave_dropdown[_settings_client.gui.autosave]); break;
|
||||||
case WID_GO_LANG_DROPDOWN: SetDParamStr(0, _current_language->own_name); break;
|
case WID_GO_LANG_DROPDOWN: SetDParamStr(0, _current_language->own_name); break;
|
||||||
case WID_GO_RESOLUTION_DROPDOWN: SetDParam(0, GetCurRes() == _num_resolutions ? STR_GAME_OPTIONS_RESOLUTION_OTHER : SPECSTR_RESOLUTION_START + GetCurRes()); break;
|
case WID_GO_RESOLUTION_DROPDOWN: SetDParam(0, GetCurRes() == _resolutions.size() ? STR_GAME_OPTIONS_RESOLUTION_OTHER : SPECSTR_RESOLUTION_START + GetCurRes()); break;
|
||||||
case WID_GO_GUI_ZOOM_DROPDOWN: SetDParam(0, _gui_zoom_dropdown[ZOOM_LVL_OUT_4X - _gui_zoom]); break;
|
case WID_GO_GUI_ZOOM_DROPDOWN: SetDParam(0, _gui_zoom_dropdown[ZOOM_LVL_OUT_4X - _gui_zoom]); break;
|
||||||
case WID_GO_FONT_ZOOM_DROPDOWN: SetDParam(0, _font_zoom_dropdown[ZOOM_LVL_OUT_4X - _font_zoom]); break;
|
case WID_GO_FONT_ZOOM_DROPDOWN: SetDParam(0, _font_zoom_dropdown[ZOOM_LVL_OUT_4X - _font_zoom]); break;
|
||||||
case WID_GO_BASE_GRF_DROPDOWN: SetDParamStr(0, BaseGraphics::GetUsedSet()->name); break;
|
case WID_GO_BASE_GRF_DROPDOWN: SetDParamStr(0, BaseGraphics::GetUsedSet()->name); break;
|
||||||
@@ -535,7 +532,7 @@ struct GameOptionsWindow : Window {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_GO_RESOLUTION_DROPDOWN: // Change resolution
|
case WID_GO_RESOLUTION_DROPDOWN: // Change resolution
|
||||||
if (index < _num_resolutions && ChangeResInGame(_resolutions[index].width, _resolutions[index].height)) {
|
if ((uint)index < _resolutions.size() && ChangeResInGame(_resolutions[index].width, _resolutions[index].height)) {
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@@ -171,8 +171,7 @@ void BuildIndustriesLegend()
|
|||||||
uint j = 0;
|
uint j = 0;
|
||||||
|
|
||||||
/* Add each name */
|
/* Add each name */
|
||||||
for (uint i = 0; i < NUM_INDUSTRYTYPES; i++) {
|
for (IndustryType ind : _sorted_industry_types) {
|
||||||
IndustryType ind = _sorted_industry_types[i];
|
|
||||||
const IndustrySpec *indsp = GetIndustrySpec(ind);
|
const IndustrySpec *indsp = GetIndustrySpec(ind);
|
||||||
if (indsp->enabled) {
|
if (indsp->enabled) {
|
||||||
_legend_from_industries[j].legend = indsp->name;
|
_legend_from_industries[j].legend = indsp->name;
|
||||||
@@ -203,7 +202,7 @@ void BuildLinkStatsLegend()
|
|||||||
memset(_legend_linkstats, 0, sizeof(_legend_linkstats));
|
memset(_legend_linkstats, 0, sizeof(_legend_linkstats));
|
||||||
|
|
||||||
uint i = 0;
|
uint i = 0;
|
||||||
for (; i < _sorted_cargo_specs_size; ++i) {
|
for (; i < _sorted_cargo_specs.size(); ++i) {
|
||||||
const CargoSpec *cs = _sorted_cargo_specs[i];
|
const CargoSpec *cs = _sorted_cargo_specs[i];
|
||||||
|
|
||||||
_legend_linkstats[i].legend = cs->name;
|
_legend_linkstats[i].legend = cs->name;
|
||||||
|
@@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
#include "core/enum_type.hpp"
|
#include "core/enum_type.hpp"
|
||||||
#include "core/bitmath_func.hpp"
|
#include "core/bitmath_func.hpp"
|
||||||
#include "core/sort_func.hpp"
|
|
||||||
#include "core/smallvec_type.hpp"
|
#include "core/smallvec_type.hpp"
|
||||||
#include "date_type.h"
|
#include "date_type.h"
|
||||||
|
|
||||||
|
@@ -444,10 +444,10 @@ void Station::RecomputeCatchment()
|
|||||||
this->catchment_tiles.Reset();
|
this->catchment_tiles.Reset();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this->catchment_tiles.Initialize(GetCatchmentRect());
|
|
||||||
|
|
||||||
if (!_settings_game.station.serve_neutral_industries && this->industry != nullptr) {
|
if (!_settings_game.station.serve_neutral_industries && this->industry != nullptr) {
|
||||||
/* Station is associated with an industry, so we only need to deliver to that industry. */
|
/* Station is associated with an industry, so we only need to deliver to that industry. */
|
||||||
|
this->catchment_tiles.Initialize(this->industry->location);
|
||||||
TILE_AREA_LOOP(tile, this->industry->location) {
|
TILE_AREA_LOOP(tile, this->industry->location) {
|
||||||
if (IsTileType(tile, MP_INDUSTRY) && GetIndustryIndex(tile) == this->industry->index) {
|
if (IsTileType(tile, MP_INDUSTRY) && GetIndustryIndex(tile) == this->industry->index) {
|
||||||
this->catchment_tiles.SetTile(tile);
|
this->catchment_tiles.SetTile(tile);
|
||||||
@@ -463,6 +463,8 @@ void Station::RecomputeCatchment()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->catchment_tiles.Initialize(GetCatchmentRect());
|
||||||
|
|
||||||
/* Loop finding all station tiles */
|
/* Loop finding all station tiles */
|
||||||
TileArea ta(TileXY(this->rect.left, this->rect.top), TileXY(this->rect.right, this->rect.bottom));
|
TileArea ta(TileXY(this->rect.left, this->rect.top), TileXY(this->rect.right, this->rect.bottom));
|
||||||
TILE_AREA_LOOP(tile, ta) {
|
TILE_AREA_LOOP(tile, ta) {
|
||||||
|
@@ -2125,14 +2125,14 @@ const char *GetCurrentLocale(const char *param)
|
|||||||
const char *GetCurrentLocale(const char *param);
|
const char *GetCurrentLocale(const char *param);
|
||||||
#endif /* !(defined(_WIN32) || defined(__APPLE__)) */
|
#endif /* !(defined(_WIN32) || defined(__APPLE__)) */
|
||||||
|
|
||||||
int CDECL StringIDSorter(const StringID *a, const StringID *b)
|
bool StringIDSorter(const StringID &a, const StringID &b)
|
||||||
{
|
{
|
||||||
char stra[512];
|
char stra[512];
|
||||||
char strb[512];
|
char strb[512];
|
||||||
GetString(stra, *a, lastof(stra));
|
GetString(stra, a, lastof(stra));
|
||||||
GetString(strb, *b, lastof(strb));
|
GetString(strb, b, lastof(strb));
|
||||||
|
|
||||||
return strnatcmp(stra, strb);
|
return strnatcmp(stra, strb) < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -240,7 +240,7 @@ extern TextDirection _current_text_dir; ///< Text direction of the currently sel
|
|||||||
void InitializeLanguagePacks();
|
void InitializeLanguagePacks();
|
||||||
const char *GetCurrentLanguageIsoCode();
|
const char *GetCurrentLanguageIsoCode();
|
||||||
|
|
||||||
int CDECL StringIDSorter(const StringID *a, const StringID *b);
|
bool StringIDSorter(const StringID &a, const StringID &b);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A searcher for missing glyphs.
|
* A searcher for missing glyphs.
|
||||||
|
@@ -19,7 +19,6 @@
|
|||||||
#include "settings_type.h"
|
#include "settings_type.h"
|
||||||
#include "cmd_helper.h"
|
#include "cmd_helper.h"
|
||||||
#include "company_base.h"
|
#include "company_base.h"
|
||||||
#include "core/sort_func.hpp"
|
|
||||||
#include "settings_type.h"
|
#include "settings_type.h"
|
||||||
#include "scope.h"
|
#include "scope.h"
|
||||||
|
|
||||||
|
@@ -36,10 +36,9 @@
|
|||||||
#include "newgrf_house.h"
|
#include "newgrf_house.h"
|
||||||
#include "date_func.h"
|
#include "date_func.h"
|
||||||
#include "core/random_func.hpp"
|
#include "core/random_func.hpp"
|
||||||
|
|
||||||
#include "widgets/town_widget.h"
|
#include "widgets/town_widget.h"
|
||||||
|
|
||||||
#include "table/strings.h"
|
#include "table/strings.h"
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include "safeguards.h"
|
#include "safeguards.h"
|
||||||
|
|
||||||
@@ -1221,11 +1220,11 @@ class GUIHouseList : public std::vector<HouseID> {
|
|||||||
protected:
|
protected:
|
||||||
std::vector<uint16> house_sets; ///< list of house sets, each item points the first house of the set in the houses array
|
std::vector<uint16> house_sets; ///< list of house sets, each item points the first house of the set in the houses array
|
||||||
|
|
||||||
static int CDECL HouseSorter(const HouseID *a, const HouseID *b)
|
static bool HouseSorter(const HouseID &a, const HouseID &b)
|
||||||
{
|
{
|
||||||
const HouseSpec *a_hs = HouseSpec::Get(*a);
|
const HouseSpec *a_hs = HouseSpec::Get(a);
|
||||||
const GRFFile *a_set = a_hs->grf_prop.grffile;
|
const GRFFile *a_set = a_hs->grf_prop.grffile;
|
||||||
const HouseSpec *b_hs = HouseSpec::Get(*b);
|
const HouseSpec *b_hs = HouseSpec::Get(b);
|
||||||
const GRFFile *b_set = b_hs->grf_prop.grffile;
|
const GRFFile *b_set = b_hs->grf_prop.grffile;
|
||||||
|
|
||||||
int ret = (a_set != nullptr) - (b_set != nullptr);
|
int ret = (a_set != nullptr) - (b_set != nullptr);
|
||||||
@@ -1235,10 +1234,10 @@ protected:
|
|||||||
ret = a_set->grfid - b_set->grfid;
|
ret = a_set->grfid - b_set->grfid;
|
||||||
if (ret == 0) ret = a_hs->grf_prop.local_id - b_hs->grf_prop.local_id;
|
if (ret == 0) ret = a_hs->grf_prop.local_id - b_hs->grf_prop.local_id;
|
||||||
} else {
|
} else {
|
||||||
ret = *a - *b;
|
ret = a - b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -1325,7 +1324,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* arrange items */
|
/* arrange items */
|
||||||
QSortT(this->data(), this->size(), HouseSorter);
|
std::sort(this->begin(), this->end(), HouseSorter);
|
||||||
|
|
||||||
/* list house sets */
|
/* list house sets */
|
||||||
this->house_sets.clear();
|
this->house_sets.clear();
|
||||||
|
@@ -28,6 +28,7 @@
|
|||||||
#include "../thread.h"
|
#include "../thread.h"
|
||||||
#include "allegro_v.h"
|
#include "allegro_v.h"
|
||||||
#include <allegro.h>
|
#include <allegro.h>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include "../safeguards.h"
|
#include "../safeguards.h"
|
||||||
|
|
||||||
@@ -139,34 +140,25 @@ static void GetVideoModes()
|
|||||||
* cards ourselves... and we need a card to get the modes. */
|
* cards ourselves... and we need a card to get the modes. */
|
||||||
set_gfx_mode(_fullscreen ? GFX_AUTODETECT_FULLSCREEN : GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
|
set_gfx_mode(_fullscreen ? GFX_AUTODETECT_FULLSCREEN : GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
|
||||||
|
|
||||||
|
_resolutions.clear();
|
||||||
|
|
||||||
GFX_MODE_LIST *mode_list = get_gfx_mode_list(gfx_driver->id);
|
GFX_MODE_LIST *mode_list = get_gfx_mode_list(gfx_driver->id);
|
||||||
if (mode_list == nullptr) {
|
if (mode_list == nullptr) {
|
||||||
memcpy(_resolutions, default_resolutions, sizeof(default_resolutions));
|
_resolutions.assign(std::begin(default_resolutions), std::end(default_resolutions));
|
||||||
_num_resolutions = lengthof(default_resolutions);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GFX_MODE *modes = mode_list->mode;
|
GFX_MODE *modes = mode_list->mode;
|
||||||
|
|
||||||
int n = 0;
|
|
||||||
for (int i = 0; modes[i].bpp != 0; i++) {
|
for (int i = 0; modes[i].bpp != 0; i++) {
|
||||||
uint w = modes[i].width;
|
uint w = modes[i].width;
|
||||||
uint h = modes[i].height;
|
uint h = modes[i].height;
|
||||||
if (w >= 640 && h >= 480) {
|
if (w < 640 || h < 480) continue;
|
||||||
int j;
|
if (std::find(_resolutions.begin(), _resolutions.end(), Dimension(w, h)) != _resolutions.end()) continue;
|
||||||
for (j = 0; j < n; j++) {
|
_resolutions.emplace_back(w, h);
|
||||||
if (_resolutions[j].width == w && _resolutions[j].height == h) break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (j == n) {
|
|
||||||
_resolutions[j].width = w;
|
|
||||||
_resolutions[j].height = h;
|
|
||||||
if (++n == lengthof(_resolutions)) break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_num_resolutions = n;
|
|
||||||
SortResolutions(_num_resolutions);
|
SortResolutions();
|
||||||
|
|
||||||
destroy_gfx_mode_list(mode_list);
|
destroy_gfx_mode_list(mode_list);
|
||||||
}
|
}
|
||||||
@@ -174,17 +166,15 @@ static void GetVideoModes()
|
|||||||
static void GetAvailableVideoMode(uint *w, uint *h)
|
static void GetAvailableVideoMode(uint *w, uint *h)
|
||||||
{
|
{
|
||||||
/* No video modes, so just try it and see where it ends */
|
/* No video modes, so just try it and see where it ends */
|
||||||
if (_num_resolutions == 0) return;
|
if (_resolutions.empty()) return;
|
||||||
|
|
||||||
/* is the wanted mode among the available modes? */
|
/* is the wanted mode among the available modes? */
|
||||||
for (int i = 0; i != _num_resolutions; i++) {
|
if (std::find(_resolutions.begin(), _resolutions.end(), Dimension(*w, *h)) != _resolutions.end()) return;
|
||||||
if (*w == _resolutions[i].width && *h == _resolutions[i].height) return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* use the closest possible resolution */
|
/* use the closest possible resolution */
|
||||||
int best = 0;
|
uint best = 0;
|
||||||
uint delta = Delta(_resolutions[0].width, *w) * Delta(_resolutions[0].height, *h);
|
uint delta = Delta(_resolutions[0].width, *w) * Delta(_resolutions[0].height, *h);
|
||||||
for (int i = 1; i != _num_resolutions; ++i) {
|
for (uint i = 1; i != _resolutions.size(); ++i) {
|
||||||
uint newdelta = Delta(_resolutions[i].width, *w) * Delta(_resolutions[i].height, *h);
|
uint newdelta = Delta(_resolutions[i].width, *w) * Delta(_resolutions[i].height, *h);
|
||||||
if (newdelta < delta) {
|
if (newdelta < delta) {
|
||||||
best = i;
|
best = i;
|
||||||
@@ -545,7 +535,7 @@ bool VideoDriver_Allegro::ToggleFullscreen(bool fullscreen)
|
|||||||
{
|
{
|
||||||
_fullscreen = fullscreen;
|
_fullscreen = fullscreen;
|
||||||
GetVideoModes(); // get the list of available video modes
|
GetVideoModes(); // get the list of available video modes
|
||||||
if (_num_resolutions == 0 || !this->ChangeResolution(_cur_resolution.width, _cur_resolution.height)) {
|
if (_resolutions.empty() || !this->ChangeResolution(_cur_resolution.width, _cur_resolution.height)) {
|
||||||
/* switching resolution failed, put back full_screen to original status */
|
/* switching resolution failed, put back full_screen to original status */
|
||||||
_fullscreen ^= true;
|
_fullscreen ^= true;
|
||||||
return false;
|
return false;
|
||||||
|
@@ -234,13 +234,13 @@ static void setupApplication()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int CDECL ModeSorter(const OTTD_Point *p1, const OTTD_Point *p2)
|
static bool ModeSorter(const OTTD_Point &p1, const OTTD_Point &p2)
|
||||||
{
|
{
|
||||||
if (p1->x < p2->x) return -1;
|
if (p1.x < p2.x) return true;
|
||||||
if (p1->x > p2->x) return +1;
|
if (p1.x > p2.x) return false;
|
||||||
if (p1->y < p2->y) return -1;
|
if (p1.y < p2.y) return true;
|
||||||
if (p1->y > p2->y) return +1;
|
if (p1.y > p2.y) return false;
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void QZ_GetDisplayModeInfo(CFArrayRef modes, CFIndex i, int &bpp, uint16 &width, uint16 &height)
|
static void QZ_GetDisplayModeInfo(CFArrayRef modes, CFIndex i, int &bpp, uint16 &width, uint16 &height)
|
||||||
@@ -326,7 +326,7 @@ uint QZ_ListModes(OTTD_Point *modes, uint max_modes, CGDirectDisplayID display_i
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Sort list smallest to largest */
|
/* Sort list smallest to largest */
|
||||||
QSortT(modes, count, &ModeSorter);
|
std::sort(modes, modes + count, ModeSorter);
|
||||||
|
|
||||||
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6)
|
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6)
|
||||||
if (MacOSVersionIsAtLeast(10, 6, 0)) CFRelease(mode_list);
|
if (MacOSVersionIsAtLeast(10, 6, 0)) CFRelease(mode_list);
|
||||||
@@ -363,12 +363,10 @@ static void QZ_UpdateVideoModes()
|
|||||||
OTTD_Point modes[32];
|
OTTD_Point modes[32];
|
||||||
uint count = _cocoa_subdriver->ListModes(modes, lengthof(modes));
|
uint count = _cocoa_subdriver->ListModes(modes, lengthof(modes));
|
||||||
|
|
||||||
|
_resolutions.clear();
|
||||||
for (uint i = 0; i < count; i++) {
|
for (uint i = 0; i < count; i++) {
|
||||||
_resolutions[i].width = modes[i].x;
|
_resolutions.emplace_back(modes[i].x, modes[i].y);
|
||||||
_resolutions[i].height = modes[i].y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_num_resolutions = count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -31,6 +31,7 @@
|
|||||||
#include "../3rdparty/mingw-std-threads/mingw.mutex.h"
|
#include "../3rdparty/mingw-std-threads/mingw.mutex.h"
|
||||||
#include "../3rdparty/mingw-std-threads/mingw.condition_variable.h"
|
#include "../3rdparty/mingw-std-threads/mingw.condition_variable.h"
|
||||||
#endif
|
#endif
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include "../safeguards.h"
|
#include "../safeguards.h"
|
||||||
|
|
||||||
@@ -211,53 +212,40 @@ static void GetVideoModes()
|
|||||||
SDL_Rect **modes = SDL_ListModes(nullptr, SDL_SWSURFACE | SDL_FULLSCREEN);
|
SDL_Rect **modes = SDL_ListModes(nullptr, SDL_SWSURFACE | SDL_FULLSCREEN);
|
||||||
if (modes == nullptr) usererror("sdl: no modes available");
|
if (modes == nullptr) usererror("sdl: no modes available");
|
||||||
|
|
||||||
|
_resolutions.clear();
|
||||||
|
|
||||||
_all_modes = (SDL_ListModes(nullptr, SDL_SWSURFACE | (_fullscreen ? SDL_FULLSCREEN : 0)) == (void*)-1);
|
_all_modes = (SDL_ListModes(nullptr, SDL_SWSURFACE | (_fullscreen ? SDL_FULLSCREEN : 0)) == (void*)-1);
|
||||||
if (modes == (void*)-1) {
|
if (modes == (void*)-1) {
|
||||||
int n = 0;
|
|
||||||
for (uint i = 0; i < lengthof(_default_resolutions); i++) {
|
for (uint i = 0; i < lengthof(_default_resolutions); i++) {
|
||||||
if (SDL_VideoModeOK(_default_resolutions[i].width, _default_resolutions[i].height, 8, SDL_FULLSCREEN) != 0) {
|
if (SDL_VideoModeOK(_default_resolutions[i].width, _default_resolutions[i].height, 8, SDL_FULLSCREEN) != 0) {
|
||||||
_resolutions[n] = _default_resolutions[i];
|
_resolutions.push_back(_default_resolutions[i]);
|
||||||
if (++n == lengthof(_resolutions)) break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_num_resolutions = n;
|
|
||||||
} else {
|
} else {
|
||||||
int n = 0;
|
|
||||||
for (int i = 0; modes[i]; i++) {
|
for (int i = 0; modes[i]; i++) {
|
||||||
uint w = modes[i]->w;
|
uint w = modes[i]->w;
|
||||||
uint h = modes[i]->h;
|
uint h = modes[i]->h;
|
||||||
if (w < 640 || h < 480) continue; // reject too small resolutions
|
if (w < 640 || h < 480) continue; // reject too small resolutions
|
||||||
int j;
|
if (std::find(_resolutions.begin(), _resolutions.end(), Dimension(w, h)) != _resolutions.end()) continue;
|
||||||
for (j = 0; j < n; j++) {
|
_resolutions.emplace_back(w, h);
|
||||||
if (_resolutions[j].width == w && _resolutions[j].height == h) break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (j == n) {
|
|
||||||
_resolutions[j].width = w;
|
|
||||||
_resolutions[j].height = h;
|
|
||||||
if (++n == lengthof(_resolutions)) break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (n == 0) usererror("No usable screen resolutions found!\n");
|
if (_resolutions.empty()) usererror("No usable screen resolutions found!\n");
|
||||||
_num_resolutions = n;
|
SortResolutions();
|
||||||
SortResolutions(_num_resolutions);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GetAvailableVideoMode(uint *w, uint *h)
|
static void GetAvailableVideoMode(uint *w, uint *h)
|
||||||
{
|
{
|
||||||
/* All modes available? */
|
/* All modes available? */
|
||||||
if (_all_modes || _num_resolutions == 0) return;
|
if (_all_modes || _resolutions.empty()) return;
|
||||||
|
|
||||||
/* Is the wanted mode among the available modes? */
|
/* Is the wanted mode among the available modes? */
|
||||||
for (int i = 0; i != _num_resolutions; i++) {
|
if (std::find(_resolutions.begin(), _resolutions.end(), Dimension(*w, *h)) != _resolutions.end()) return;
|
||||||
if (*w == _resolutions[i].width && *h == _resolutions[i].height) return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Use the closest possible resolution */
|
/* Use the closest possible resolution */
|
||||||
int best = 0;
|
uint best = 0;
|
||||||
uint delta = Delta(_resolutions[0].width, *w) * Delta(_resolutions[0].height, *h);
|
uint delta = Delta(_resolutions[0].width, *w) * Delta(_resolutions[0].height, *h);
|
||||||
for (int i = 1; i != _num_resolutions; ++i) {
|
for (uint i = 1; i != _resolutions.size(); ++i) {
|
||||||
uint newdelta = Delta(_resolutions[i].width, *w) * Delta(_resolutions[i].height, *h);
|
uint newdelta = Delta(_resolutions[i].width, *w) * Delta(_resolutions[i].height, *h);
|
||||||
if (newdelta < delta) {
|
if (newdelta < delta) {
|
||||||
best = i;
|
best = i;
|
||||||
@@ -821,7 +809,7 @@ bool VideoDriver_SDL::ToggleFullscreen(bool fullscreen)
|
|||||||
|
|
||||||
_fullscreen = fullscreen;
|
_fullscreen = fullscreen;
|
||||||
GetVideoModes(); // get the list of available video modes
|
GetVideoModes(); // get the list of available video modes
|
||||||
bool ret = _num_resolutions != 0 && CreateMainSurface(_cur_resolution.width, _cur_resolution.height);
|
bool ret = !_resolutions.empty() && CreateMainSurface(_cur_resolution.width, _cur_resolution.height);
|
||||||
|
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
/* switching resolution failed, put back full_screen to original status */
|
/* switching resolution failed, put back full_screen to original status */
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include "../driver.h"
|
#include "../driver.h"
|
||||||
#include "../core/geometry_type.hpp"
|
#include "../core/geometry_type.hpp"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
/** The base of all video drivers. */
|
/** The base of all video drivers. */
|
||||||
class VideoDriver : public Driver {
|
class VideoDriver : public Driver {
|
||||||
@@ -101,8 +102,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern char *_ini_videodriver;
|
extern char *_ini_videodriver;
|
||||||
extern int _num_resolutions;
|
extern std::vector<Dimension> _resolutions;
|
||||||
extern Dimension _resolutions[32];
|
|
||||||
extern Dimension _cur_resolution;
|
extern Dimension _cur_resolution;
|
||||||
extern bool _rightclick_emulate;
|
extern bool _rightclick_emulate;
|
||||||
|
|
||||||
|
@@ -33,6 +33,7 @@
|
|||||||
#include "../3rdparty/mingw-std-threads/mingw.mutex.h"
|
#include "../3rdparty/mingw-std-threads/mingw.mutex.h"
|
||||||
#include "../3rdparty/mingw-std-threads/mingw.condition_variable.h"
|
#include "../3rdparty/mingw-std-threads/mingw.condition_variable.h"
|
||||||
#endif
|
#endif
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include "../safeguards.h"
|
#include "../safeguards.h"
|
||||||
|
|
||||||
@@ -1089,45 +1090,29 @@ static const Dimension default_resolutions[] = {
|
|||||||
|
|
||||||
static void FindResolutions()
|
static void FindResolutions()
|
||||||
{
|
{
|
||||||
uint n = 0;
|
|
||||||
uint i;
|
uint i;
|
||||||
DEVMODEA dm;
|
DEVMODEA dm;
|
||||||
|
|
||||||
/* Check modes for the relevant fullscreen bpp */
|
/* Check modes for the relevant fullscreen bpp */
|
||||||
uint bpp = _support8bpp != S8BPP_HARDWARE ? 32 : BlitterFactory::GetCurrentBlitter()->GetScreenDepth();
|
uint bpp = _support8bpp != S8BPP_HARDWARE ? 32 : BlitterFactory::GetCurrentBlitter()->GetScreenDepth();
|
||||||
|
|
||||||
|
_resolutions.clear();
|
||||||
|
|
||||||
/* XXX - EnumDisplaySettingsW crashes with unicows.dll on Windows95
|
/* XXX - EnumDisplaySettingsW crashes with unicows.dll on Windows95
|
||||||
* Doesn't really matter since we don't pass a string anyways, but still
|
* Doesn't really matter since we don't pass a string anyways, but still
|
||||||
* a letdown */
|
* a letdown */
|
||||||
for (i = 0; EnumDisplaySettingsA(nullptr, i, &dm) != 0; i++) {
|
for (i = 0; EnumDisplaySettingsA(nullptr, i, &dm) != 0; i++) {
|
||||||
if (dm.dmBitsPerPel == bpp &&
|
if (dm.dmBitsPerPel != bpp || dm.dmPelsWidth < 640 || dm.dmPelsHeight < 480) continue;
|
||||||
dm.dmPelsWidth >= 640 && dm.dmPelsHeight >= 480) {
|
if (std::find(_resolutions.begin(), _resolutions.end(), Dimension(dm.dmPelsWidth, dm.dmPelsHeight)) != _resolutions.end()) continue;
|
||||||
uint j;
|
_resolutions.emplace_back(dm.dmPelsWidth, dm.dmPelsHeight);
|
||||||
|
|
||||||
for (j = 0; j < n; j++) {
|
|
||||||
if (_resolutions[j].width == dm.dmPelsWidth && _resolutions[j].height == dm.dmPelsHeight) break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* In the previous loop we have checked already existing/added resolutions if
|
|
||||||
* they are the same as the new ones. If this is not the case (j == n); we have
|
|
||||||
* looped all and found none, add the new one to the list. If we have reached the
|
|
||||||
* maximum amount of resolutions, then quit querying the display */
|
|
||||||
if (j == n) {
|
|
||||||
_resolutions[j].width = dm.dmPelsWidth;
|
|
||||||
_resolutions[j].height = dm.dmPelsHeight;
|
|
||||||
if (++n == lengthof(_resolutions)) break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We have found no resolutions, show the default list */
|
/* We have found no resolutions, show the default list */
|
||||||
if (n == 0) {
|
if (_resolutions.empty()) {
|
||||||
memcpy(_resolutions, default_resolutions, sizeof(default_resolutions));
|
_resolutions.assign(std::begin(default_resolutions), std::end(default_resolutions));
|
||||||
n = lengthof(default_resolutions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_num_resolutions = n;
|
SortResolutions();
|
||||||
SortResolutions(_num_resolutions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static FVideoDriver_Win32 iFVideoDriver_Win32;
|
static FVideoDriver_Win32 iFVideoDriver_Win32;
|
||||||
|
@@ -3188,15 +3188,17 @@ static bool CheckClickOnViewportSign(const ViewPort *vp, int x, int y, const Vie
|
|||||||
*/
|
*/
|
||||||
static bool CheckClickOnViewportSign(const ViewPort *vp, int x, int y)
|
static bool CheckClickOnViewportSign(const ViewPort *vp, int x, int y)
|
||||||
{
|
{
|
||||||
|
if (_game_mode == GM_MENU) return false;
|
||||||
|
|
||||||
x = ScaleByZoom(x - vp->left, vp->zoom) + vp->virtual_left;
|
x = ScaleByZoom(x - vp->left, vp->zoom) + vp->virtual_left;
|
||||||
y = ScaleByZoom(y - vp->top, vp->zoom) + vp->virtual_top;
|
y = ScaleByZoom(y - vp->top, vp->zoom) + vp->virtual_top;
|
||||||
|
|
||||||
Rect search_rect{ x - 1, y - 1, x + 1, y + 1 };
|
Rect search_rect{ x - 1, y - 1, x + 1, y + 1 };
|
||||||
search_rect = ExpandRectWithViewportSignMargins(search_rect, vp->zoom);
|
search_rect = ExpandRectWithViewportSignMargins(search_rect, vp->zoom);
|
||||||
|
|
||||||
bool show_stations = HasBit(_display_opt, DO_SHOW_STATION_NAMES) && _game_mode != GM_MENU;
|
bool show_stations = HasBit(_display_opt, DO_SHOW_STATION_NAMES) && !IsInvisibilitySet(TO_SIGNS);
|
||||||
bool show_waypoints = HasBit(_display_opt, DO_SHOW_WAYPOINT_NAMES) && _game_mode != GM_MENU;
|
bool show_waypoints = HasBit(_display_opt, DO_SHOW_WAYPOINT_NAMES) && !IsInvisibilitySet(TO_SIGNS);
|
||||||
bool show_towns = HasBit(_display_opt, DO_SHOW_TOWN_NAMES) && _game_mode != GM_MENU;
|
bool show_towns = HasBit(_display_opt, DO_SHOW_TOWN_NAMES);
|
||||||
bool show_signs = HasBit(_display_opt, DO_SHOW_SIGNS) && !IsInvisibilitySet(TO_SIGNS);
|
bool show_signs = HasBit(_display_opt, DO_SHOW_SIGNS) && !IsInvisibilitySet(TO_SIGNS);
|
||||||
bool show_competitors = HasBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS);
|
bool show_competitors = HasBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user