msvc min/max fixes
This commit is contained in:
parent
f9b512a502
commit
6d6a615a37
@ -6,6 +6,7 @@
|
|||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "Misc.h"
|
#include "Misc.h"
|
||||||
#include "icondoc.h"
|
#include "icondoc.h"
|
||||||
|
#include "common/tpt-minmax.h"
|
||||||
|
|
||||||
//Signum function
|
//Signum function
|
||||||
int isign(float i) //TODO: INline or macro
|
int isign(float i) //TODO: INline or macro
|
||||||
@ -252,10 +253,10 @@ void RGB_to_HSV(int r,int g,int b,int *h,int *s,int *v)//convert 0-255 RGB value
|
|||||||
rr = r/255.0f;//normalize values
|
rr = r/255.0f;//normalize values
|
||||||
gg = g/255.0f;
|
gg = g/255.0f;
|
||||||
bb = b/255.0f;
|
bb = b/255.0f;
|
||||||
a = fmin(rr,gg);
|
a = std::min(rr,gg);
|
||||||
a = fmin(a,bb);
|
a = std::min(a,bb);
|
||||||
x = fmax(rr,gg);
|
x = std::max(rr,gg);
|
||||||
x = fmax(x,bb);
|
x = std::max(x,bb);
|
||||||
if (a==x)//greyscale
|
if (a==x)//greyscale
|
||||||
{
|
{
|
||||||
*h = 0;
|
*h = 0;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#include "common/tpt-minmax.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
36
src/common/tpt-minmax.h
Normal file
36
src/common/tpt-minmax.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* This program 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; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TPT_MINMAX_H
|
||||||
|
#define TPT_MINMAX_H
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
// less than VS2013. Untested since I don't use VS2012 anymore
|
||||||
|
#if _MSC_VER < 1800
|
||||||
|
#define fmin min
|
||||||
|
#define fminf min
|
||||||
|
#define fmax max
|
||||||
|
#define fmaxf max
|
||||||
|
#else
|
||||||
|
// >= VS2013
|
||||||
|
#include <algorithm>
|
||||||
|
#define NOMINMAX
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
// not using visual studio, std::min and std::max are normal
|
||||||
|
#include <algorithm>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
@ -13,6 +13,7 @@
|
|||||||
#include "client/Client.h"
|
#include "client/Client.h"
|
||||||
#include "client/GameSave.h"
|
#include "client/GameSave.h"
|
||||||
#include "client/SaveFile.h"
|
#include "client/SaveFile.h"
|
||||||
|
#include "common/tpt-minmax.h"
|
||||||
#include "gui/game/DecorationTool.h"
|
#include "gui/game/DecorationTool.h"
|
||||||
#include "QuickOptions.h"
|
#include "QuickOptions.h"
|
||||||
#include "GameModelException.h"
|
#include "GameModelException.h"
|
||||||
@ -119,10 +120,10 @@ GameModel::GameModel():
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Set default decoration colour
|
//Set default decoration colour
|
||||||
unsigned char colourR = min(Client::Ref().GetPrefInteger("Decoration.Red", 200), 255);
|
unsigned char colourR = std::min(Client::Ref().GetPrefInteger("Decoration.Red", 200), 255);
|
||||||
unsigned char colourG = min(Client::Ref().GetPrefInteger("Decoration.Green", 100), 255);
|
unsigned char colourG = std::min(Client::Ref().GetPrefInteger("Decoration.Green", 100), 255);
|
||||||
unsigned char colourB = min(Client::Ref().GetPrefInteger("Decoration.Blue", 50), 255);
|
unsigned char colourB = std::min(Client::Ref().GetPrefInteger("Decoration.Blue", 50), 255);
|
||||||
unsigned char colourA = min(Client::Ref().GetPrefInteger("Decoration.Alpha", 255), 255);
|
unsigned char colourA = std::min(Client::Ref().GetPrefInteger("Decoration.Alpha", 255), 255);
|
||||||
|
|
||||||
SetColourSelectorColour(ui::Colour(colourR, colourG, colourB, colourA));
|
SetColourSelectorColour(ui::Colour(colourR, colourG, colourB, colourA));
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "ContextMenu.h"
|
#include "ContextMenu.h"
|
||||||
|
#include "common/tpt-minmax.h"
|
||||||
|
|
||||||
using namespace ui;
|
using namespace ui;
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "ProgressBar.h"
|
#include "ProgressBar.h"
|
||||||
|
#include "common/tpt-minmax.h"
|
||||||
#include "gui/Style.h"
|
#include "gui/Style.h"
|
||||||
|
|
||||||
using namespace ui;
|
using namespace ui;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "ScrollPanel.h"
|
#include "ScrollPanel.h"
|
||||||
|
#include "common/tpt-minmax.h"
|
||||||
|
|
||||||
using namespace ui;
|
using namespace ui;
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include "Format.h"
|
#include "Format.h"
|
||||||
#include "client/Client.h"
|
#include "client/Client.h"
|
||||||
#include "client/GameSave.h"
|
#include "client/GameSave.h"
|
||||||
|
#include "common/tpt-minmax.h"
|
||||||
#include "gui/dialogues/ErrorMessage.h"
|
#include "gui/dialogues/ErrorMessage.h"
|
||||||
#include "PreviewModelException.h"
|
#include "PreviewModelException.h"
|
||||||
|
|
||||||
@ -124,7 +125,7 @@ int PreviewModel::GetCommentsPageNum()
|
|||||||
|
|
||||||
int PreviewModel::GetCommentsPageCount()
|
int PreviewModel::GetCommentsPageCount()
|
||||||
{
|
{
|
||||||
return max(1, (int)(ceil(commentsTotal/20.0f)));
|
return std::max(1, (int)(ceil(commentsTotal/20.0f)));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PreviewModel::GetCommentsLoaded()
|
bool PreviewModel::GetCommentsLoaded()
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include "common/tpt-minmax.h"
|
||||||
#include "common/tpt-thread.h"
|
#include "common/tpt-thread.h"
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include "client/SaveInfo.h"
|
#include "client/SaveInfo.h"
|
||||||
@ -63,9 +64,9 @@ public:
|
|||||||
int GetPageCount()
|
int GetPageCount()
|
||||||
{
|
{
|
||||||
if (!showOwn && !showFavourite && currentSort == "best" && lastQuery == "")
|
if (!showOwn && !showFavourite && currentSort == "best" && lastQuery == "")
|
||||||
return max(1, (int)(ceil(resultCount/20.0f))+1); //add one for front page (front page saves are repeated twice)
|
return std::max(1, (int)(ceil(resultCount/20.0f))+1); //add one for front page (front page saves are repeated twice)
|
||||||
else
|
else
|
||||||
return max(1, (int)(ceil(resultCount/20.0f)));
|
return std::max(1, (int)(ceil(resultCount/20.0f)));
|
||||||
}
|
}
|
||||||
int GetPageNum() { return currentPage; }
|
int GetPageNum() { return currentPage; }
|
||||||
std::string GetLastQuery() { return lastQuery; }
|
std::string GetLastQuery() { return lastQuery; }
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include "common/tpt-minmax.h"
|
||||||
#include "gui/interface/Label.h"
|
#include "gui/interface/Label.h"
|
||||||
#include "TaskWindow.h"
|
#include "TaskWindow.h"
|
||||||
#include "gui/dialogues/ErrorMessage.h"
|
#include "gui/dialogues/ErrorMessage.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user