mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-07-21 15:30:33 +00:00
fix: assign ownerdraw item type when parsing menus (#911)
Set `m_type` to `ITEM_TYPE_OWNERDRAW` when parsing an `ownerdraw` property. Otherwise, it retains the default `ITEM_TYPE_TEXT`. This restores controls such as the Source button in the IW4x server browser.
This commit is contained in:
@@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
using namespace menu;
|
using namespace menu;
|
||||||
|
|
||||||
|
constexpr auto ITEM_TYPE_OWNERDRAW = 8;
|
||||||
|
|
||||||
class ItemScopeOperations
|
class ItemScopeOperations
|
||||||
{
|
{
|
||||||
inline static const CommonItemFeatureType IW4_FEATURE_TYPE_BY_TYPE[0x18]{
|
inline static const CommonItemFeatureType IW4_FEATURE_TYPE_BY_TYPE[0x18]{
|
||||||
@@ -705,6 +707,7 @@ void ItemScopeSequences::AddSequences(FeatureLevel featureLevel, bool permissive
|
|||||||
AddSequence(std::make_unique<GenericIntPropertySequence>("ownerdraw",
|
AddSequence(std::make_unique<GenericIntPropertySequence>("ownerdraw",
|
||||||
[](const MenuFileParserState* state, const TokenPos&, const int value)
|
[](const MenuFileParserState* state, const TokenPos&, const int value)
|
||||||
{
|
{
|
||||||
|
state->m_current_item->m_type = ITEM_TYPE_OWNERDRAW;
|
||||||
state->m_current_item->m_owner_draw = value;
|
state->m_current_item->m_owner_draw = value;
|
||||||
}));
|
}));
|
||||||
AddSequence(std::make_unique<GenericIntPropertySequence>("align",
|
AddSequence(std::make_unique<GenericIntPropertySequence>("align",
|
||||||
|
|||||||
@@ -334,6 +334,28 @@ namespace test::parsing::menu::sequence::item
|
|||||||
REQUIRE(item->m_rect.verticalAlign == 0);
|
REQUIRE(item->m_rect.verticalAlign == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("ItemScopeSequences: Ownerdraw sets the ownerdraw item type", "[parsing][sequence][menu]")
|
||||||
|
{
|
||||||
|
ItemSequenceTestsHelper helper(FeatureLevel::IW4, false);
|
||||||
|
const TokenPos pos;
|
||||||
|
helper.Tokens({
|
||||||
|
SimpleParserValue::Identifier(pos, new std::string("ownerdraw")),
|
||||||
|
SimpleParserValue::Integer(pos, 220),
|
||||||
|
SimpleParserValue::EndOfFile(pos),
|
||||||
|
});
|
||||||
|
|
||||||
|
const auto result = helper.PerformTest();
|
||||||
|
|
||||||
|
REQUIRE(result);
|
||||||
|
REQUIRE(helper.m_consumed_token_count == 2);
|
||||||
|
|
||||||
|
const auto* item = helper.m_state->m_current_item;
|
||||||
|
REQUIRE(item);
|
||||||
|
|
||||||
|
REQUIRE(item->m_owner_draw == 220);
|
||||||
|
REQUIRE(item->m_type == 8); // ITEM_TYPE_OWNERDRAW
|
||||||
|
}
|
||||||
|
|
||||||
TEST_CASE("ItemScopeSequences: Simple dvarStrList works", "[parsing][sequence][menu]")
|
TEST_CASE("ItemScopeSequences: Simple dvarStrList works", "[parsing][sequence][menu]")
|
||||||
{
|
{
|
||||||
ItemSequenceTestsHelper helper(FeatureLevel::IW4, false);
|
ItemSequenceTestsHelper helper(FeatureLevel::IW4, false);
|
||||||
|
|||||||
Reference in New Issue
Block a user