ManaPlus
textchunksmall.cpp
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2011-2019 The ManaPlus Developers
4  * Copyright (C) 2019-2021 Andrei Karas
5  *
6  * This file is part of The ManaPlus Client.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
23 
24 #include "gui/fonts/font.h"
25 
26 #include "debug.h"
27 
28 TextChunkSmall::TextChunkSmall(const std::string &text0,
29  const Color &color0,
30  const Color &color1) :
31  text(text0),
32  color(color0),
33  color2(color1)
34 {
35 }
36 
38  text(old.text),
39  color(old.color),
40  color2(old.color2)
41 {
42 }
43 
45 {
46  text = chunk.text;
47  color = chunk.color;
48  color2 = chunk.color2;
49  return *this;
50 }
51 
53 {
54  return chunk.text == text &&
55  chunk.color == color &&
56  chunk.color2 == color2;
57 }
58 
59 bool TextChunkSmall::operator<(const TextChunkSmall &chunk) const
60 {
61  if (chunk.text != text)
62  return chunk.text > text;
63 
64  const Color &restrict c = chunk.color;
65  if (c.r != color.r)
66  return c.r > color.r;
67  if (c.g != color.g)
68  return c.g > color.g;
69  if (c.b != color.b)
70  return c.b > color.b;
71 
72  const Color &restrict c2 = chunk.color2;
73  if (c2.r != color2.r)
74  return c2.r > color2.r;
75  if (c2.g != color2.g)
76  return c2.g > color2.g;
77  if (c2.b != color2.b)
78  return c2.b > color2.b;
79 
80  if (c.a != color.a && Font::mSoftMode)
81  return c.a > color.a;
82 
83  return false;
84 }
Definition: color.h:76
unsigned int a
Definition: color.h:251
unsigned int b
Definition: color.h:245
unsigned int r
Definition: color.h:235
unsigned int g
Definition: color.h:240
static bool mSoftMode
Definition: font.h:140
TextChunkSmall(const std::string &text0, const Color &color0, const Color &color1)
bool operator==(const TextChunkSmall &chunk) const
TextChunkSmall & operator=(const TextChunkSmall &chunk)
std::string text
bool operator<(const TextChunkSmall &chunk) const
#define restrict
Definition: localconsts.h:165