mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-23 15:52:55 +01:00
Merge pull request #13669 from ZehMatt/enhancements/banner-limit
Refactor logic to allow to draw 256 banners at the same time
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
#include "../ui/UiContext.h"
|
#include "../ui/UiContext.h"
|
||||||
#include "../util/Util.h"
|
#include "../util/Util.h"
|
||||||
#include "Drawing.h"
|
#include "Drawing.h"
|
||||||
|
#include "ScrollingText.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -180,6 +181,7 @@ void mask_scalar(
|
|||||||
static rct_gx _g1 = {};
|
static rct_gx _g1 = {};
|
||||||
static rct_gx _g2 = {};
|
static rct_gx _g2 = {};
|
||||||
static rct_gx _csg = {};
|
static rct_gx _csg = {};
|
||||||
|
static rct_g1_element _scrollingText[MaxScrollingTextEntries]{};
|
||||||
static bool _csgLoaded = false;
|
static bool _csgLoaded = false;
|
||||||
|
|
||||||
static rct_g1_element _g1Temp = {};
|
static rct_g1_element _g1Temp = {};
|
||||||
@@ -701,6 +703,14 @@ const rct_g1_element* gfx_get_g1_element(int32_t image_id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (offset < SPR_SCROLLING_TEXT_END)
|
||||||
|
{
|
||||||
|
size_t idx = offset - SPR_SCROLLING_TEXT_START;
|
||||||
|
if (idx < std::size(_scrollingText))
|
||||||
|
{
|
||||||
|
return &_scrollingText[idx];
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (offset < SPR_IMAGE_LIST_END)
|
else if (offset < SPR_IMAGE_LIST_END)
|
||||||
{
|
{
|
||||||
size_t idx = offset - SPR_IMAGE_LIST_BEGIN;
|
size_t idx = offset - SPR_IMAGE_LIST_BEGIN;
|
||||||
@@ -739,6 +749,14 @@ void gfx_set_g1_element(int32_t imageId, const rct_g1_element* g1)
|
|||||||
_g1.elements[imageId] = *g1;
|
_g1.elements[imageId] = *g1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (imageId < SPR_SCROLLING_TEXT_END)
|
||||||
|
{
|
||||||
|
size_t idx = static_cast<size_t>(imageId) - SPR_SCROLLING_TEXT_START;
|
||||||
|
if (idx < std::size(_scrollingText))
|
||||||
|
{
|
||||||
|
_scrollingText[idx] = *g1;
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
size_t idx = static_cast<size_t>(imageId) - SPR_IMAGE_LIST_BEGIN;
|
size_t idx = static_cast<size_t>(imageId) - SPR_IMAGE_LIST_BEGIN;
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include "ScrollingText.h"
|
||||||
|
|
||||||
#include "../config/Config.h"
|
#include "../config/Config.h"
|
||||||
#include "../core/String.hpp"
|
#include "../core/String.hpp"
|
||||||
#include "../interface/Colour.h"
|
#include "../interface/Colour.h"
|
||||||
@@ -34,9 +36,7 @@ struct rct_draw_scroll_text
|
|||||||
uint8_t bitmap[64 * 40];
|
uint8_t bitmap[64 * 40];
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr int32_t MAX_SCROLLING_TEXT_ENTRIES = 32;
|
static rct_draw_scroll_text _drawScrollTextList[OpenRCT2::MaxScrollingTextEntries];
|
||||||
|
|
||||||
static rct_draw_scroll_text _drawScrollTextList[MAX_SCROLLING_TEXT_ENTRIES];
|
|
||||||
static uint8_t _characterBitmaps[FONT_SPRITE_GLYPH_COUNT + SPR_G2_GLYPH_COUNT][8];
|
static uint8_t _characterBitmaps[FONT_SPRITE_GLYPH_COUNT + SPR_G2_GLYPH_COUNT][8];
|
||||||
static uint32_t _drawSCrollNextIndex = 0;
|
static uint32_t _drawSCrollNextIndex = 0;
|
||||||
static std::mutex _scrollingTextMutex;
|
static std::mutex _scrollingTextMutex;
|
||||||
@@ -97,24 +97,26 @@ void scrolling_text_initialise_bitmaps()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < MAX_SCROLLING_TEXT_ENTRIES; i++)
|
for (int32_t i = 0; i < OpenRCT2::MaxScrollingTextEntries; i++)
|
||||||
{
|
{
|
||||||
int32_t imageId = SPR_SCROLLING_TEXT_START + i;
|
const int32_t imageId = SPR_SCROLLING_TEXT_START + i;
|
||||||
const rct_g1_element* g1original = gfx_get_g1_element(imageId);
|
|
||||||
if (g1original != nullptr)
|
// Initialize the scrolling text sprite.
|
||||||
{
|
rct_g1_element g1{};
|
||||||
rct_g1_element g1 = *g1original;
|
g1.offset = _drawScrollTextList[i].bitmap;
|
||||||
g1.offset = _drawScrollTextList[i].bitmap;
|
g1.x_offset = -32;
|
||||||
g1.width = 64;
|
g1.y_offset = 0;
|
||||||
g1.height = 40;
|
g1.flags = G1_FLAG_BMP;
|
||||||
g1.offset[0] = 0xFF;
|
g1.width = 64;
|
||||||
g1.offset[1] = 0xFF;
|
g1.height = 40;
|
||||||
g1.offset[14] = 0;
|
g1.offset[0] = 0xFF;
|
||||||
g1.offset[15] = 0;
|
g1.offset[1] = 0xFF;
|
||||||
g1.offset[16] = 0;
|
g1.offset[14] = 0;
|
||||||
g1.offset[17] = 0;
|
g1.offset[15] = 0;
|
||||||
gfx_set_g1_element(imageId, &g1);
|
g1.offset[16] = 0;
|
||||||
}
|
g1.offset[17] = 0;
|
||||||
|
|
||||||
|
gfx_set_g1_element(imageId, &g1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,13 +138,13 @@ static int32_t scrolling_text_get_matching_or_oldest(
|
|||||||
{
|
{
|
||||||
uint32_t oldestId = 0xFFFFFFFF;
|
uint32_t oldestId = 0xFFFFFFFF;
|
||||||
int32_t scrollIndex = -1;
|
int32_t scrollIndex = -1;
|
||||||
for (int32_t i = 0; i < MAX_SCROLLING_TEXT_ENTRIES; i++)
|
for (size_t i = 0; i < std::size(_drawScrollTextList); i++)
|
||||||
{
|
{
|
||||||
rct_draw_scroll_text* scrollText = &_drawScrollTextList[i];
|
rct_draw_scroll_text* scrollText = &_drawScrollTextList[i];
|
||||||
if (oldestId >= scrollText->id)
|
if (oldestId >= scrollText->id)
|
||||||
{
|
{
|
||||||
oldestId = scrollText->id;
|
oldestId = scrollText->id;
|
||||||
scrollIndex = i;
|
scrollIndex = static_cast<int32_t>(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If exact match return the matching index
|
// If exact match return the matching index
|
||||||
@@ -151,7 +153,7 @@ static int32_t scrolling_text_get_matching_or_oldest(
|
|||||||
&& scrollText->colour == colour && scrollText->position == scroll && scrollText->mode == scrollingMode)
|
&& scrollText->colour == colour && scrollText->position == scroll && scrollText->mode == scrollingMode)
|
||||||
{
|
{
|
||||||
scrollText->id = _drawSCrollNextIndex;
|
scrollText->id = _drawSCrollNextIndex;
|
||||||
return i + SPR_SCROLLING_TEXT_START;
|
return static_cast<int32_t>(i + SPR_SCROLLING_TEXT_START);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return scrollIndex;
|
return scrollIndex;
|
||||||
@@ -1437,9 +1439,8 @@ static constexpr const int16_t* _scrollPositions[MAX_SCROLLING_TEXT_MODES] = {
|
|||||||
|
|
||||||
void scrolling_text_invalidate()
|
void scrolling_text_invalidate()
|
||||||
{
|
{
|
||||||
for (int32_t i = 0; i < MAX_SCROLLING_TEXT_ENTRIES; i++)
|
for (auto& scrollText : _drawScrollTextList)
|
||||||
{
|
{
|
||||||
rct_draw_scroll_text& scrollText = _drawScrollTextList[i];
|
|
||||||
scrollText.string_id = 0;
|
scrollText.string_id = 0;
|
||||||
std::memset(scrollText.string_args, 0, sizeof(scrollText.string_args));
|
std::memset(scrollText.string_args, 0, sizeof(scrollText.string_args));
|
||||||
}
|
}
|
||||||
|
|||||||
8
src/openrct2/drawing/ScrollingText.h
Normal file
8
src/openrct2/drawing/ScrollingText.h
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace OpenRCT2
|
||||||
|
{
|
||||||
|
static auto constexpr MaxScrollingTextLegacyEntries = 32;
|
||||||
|
static auto constexpr MaxScrollingTextEntries = 256;
|
||||||
|
|
||||||
|
} // namespace OpenRCT2
|
||||||
@@ -190,6 +190,7 @@
|
|||||||
<ClInclude Include="drawing\ImageImporter.h" />
|
<ClInclude Include="drawing\ImageImporter.h" />
|
||||||
<ClInclude Include="drawing\LightFX.h" />
|
<ClInclude Include="drawing\LightFX.h" />
|
||||||
<ClInclude Include="drawing\NewDrawing.h" />
|
<ClInclude Include="drawing\NewDrawing.h" />
|
||||||
|
<ClInclude Include="drawing\ScrollingText.h" />
|
||||||
<ClInclude Include="drawing\Weather.h" />
|
<ClInclude Include="drawing\Weather.h" />
|
||||||
<ClInclude Include="drawing\Text.h" />
|
<ClInclude Include="drawing\Text.h" />
|
||||||
<ClInclude Include="drawing\TTF.h" />
|
<ClInclude Include="drawing\TTF.h" />
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#ifndef _SPRITES_H_
|
#ifndef _SPRITES_H_
|
||||||
#define _SPRITES_H_
|
#define _SPRITES_H_
|
||||||
|
|
||||||
|
#include "drawing/ScrollingText.h"
|
||||||
#include "rct1/RCT1.h"
|
#include "rct1/RCT1.h"
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@@ -19,8 +20,8 @@ enum
|
|||||||
// Used for on-demand drawing of dynamic memory
|
// Used for on-demand drawing of dynamic memory
|
||||||
SPR_TEMP = 0x7FFFE,
|
SPR_TEMP = 0x7FFFE,
|
||||||
|
|
||||||
SPR_SCROLLING_TEXT_START = 1542,
|
SPR_SCROLLING_TEXT_LEGACY_START = 1542,
|
||||||
SPR_SCROLLING_TEXT_END = SPR_SCROLLING_TEXT_START + 32,
|
SPR_SCROLLING_TEXT_LEGACY_END = SPR_SCROLLING_TEXT_LEGACY_START + OpenRCT2::MaxScrollingTextLegacyEntries,
|
||||||
SPR_SCROLLING_TEXT_DEFAULT = 1574,
|
SPR_SCROLLING_TEXT_DEFAULT = 1574,
|
||||||
|
|
||||||
SPR_EDGE_ROCK_BASE = 1579,
|
SPR_EDGE_ROCK_BASE = 1579,
|
||||||
@@ -1037,7 +1038,10 @@ enum
|
|||||||
SPR_CSG_BEGIN = SPR_G2_END,
|
SPR_CSG_BEGIN = SPR_G2_END,
|
||||||
SPR_CSG_END = SPR_CSG_BEGIN + RCT1_NUM_LL_CSG_ENTRIES,
|
SPR_CSG_END = SPR_CSG_BEGIN + RCT1_NUM_LL_CSG_ENTRIES,
|
||||||
|
|
||||||
SPR_IMAGE_LIST_BEGIN = SPR_CSG_END,
|
SPR_SCROLLING_TEXT_START = SPR_CSG_END,
|
||||||
|
SPR_SCROLLING_TEXT_END = SPR_SCROLLING_TEXT_START + OpenRCT2::MaxScrollingTextEntries,
|
||||||
|
|
||||||
|
SPR_IMAGE_LIST_BEGIN = SPR_SCROLLING_TEXT_END,
|
||||||
SPR_IMAGE_LIST_END = 0x7FFFE
|
SPR_IMAGE_LIST_END = 0x7FFFE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user