mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
@@ -31,6 +31,10 @@
|
||||
the background behind cards. */
|
||||
--secondary-background-color: #303030;
|
||||
--paper-progress-container-color: var(--secondary-background-color);
|
||||
|
||||
/* --loot-plugin-item-index-border-color is used to control the colour of the
|
||||
border around load order indices in the sidebar. */
|
||||
--loot-plugin-item-index-border-color: var(--paper-color-300);
|
||||
}
|
||||
|
||||
#main {
|
||||
|
||||
@@ -196,4 +196,37 @@ bool Game::IsPluginActive(const std::string& pluginName) const {
|
||||
return LoadOrderHandler::IsPluginActive(pluginName);
|
||||
}
|
||||
}
|
||||
|
||||
short Game::GetActiveLoadOrderIndex(const std::string & pluginName) const {
|
||||
// Get the full load order, then count the number of active plugins until the
|
||||
// given plugin is encountered. If the plugin isn't active or in the load
|
||||
// order, return -1.
|
||||
|
||||
if (!IsPluginActive(pluginName))
|
||||
return -1;
|
||||
|
||||
short numberOfActivePlugins = 0;
|
||||
for (const std::string& plugin : GetLoadOrder()) {
|
||||
if (boost::iequals(plugin, pluginName))
|
||||
return numberOfActivePlugins;
|
||||
|
||||
if (IsPluginActive(plugin))
|
||||
++numberOfActivePlugins;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
std::list<std::string> Game::GetLoadOrder() const {
|
||||
if (loadOrder_.empty())
|
||||
loadOrder_ = LoadOrderHandler::GetLoadOrder();
|
||||
|
||||
return loadOrder_;
|
||||
}
|
||||
void Game::SetLoadOrder(const std::list<std::string>& loadOrder) const {
|
||||
LoadOrderHandler::SetLoadOrder(loadOrder);
|
||||
loadOrder_ = loadOrder;
|
||||
}
|
||||
void Game::SetLoadOrder(const char * const * const loadOrder, const size_t numPlugins) const {
|
||||
LoadOrderHandler::SetLoadOrder(loadOrder, numPlugins);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,8 +51,14 @@ public:
|
||||
// Check if the plugin is active by using the cached value if
|
||||
// available, and otherwise asking the load order handler.
|
||||
bool IsPluginActive(const std::string& pluginName) const;
|
||||
short GetActiveLoadOrderIndex(const std::string & pluginName) const;
|
||||
|
||||
std::list<std::string> GetLoadOrder() const;
|
||||
void SetLoadOrder(const std::list<std::string>& loadOrder) const;
|
||||
void SetLoadOrder(const char * const * const loadOrder, const size_t numPlugins) const;
|
||||
private:
|
||||
bool pluginsFullyLoaded_;
|
||||
mutable std::list<std::string> loadOrder_;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
}
|
||||
|
||||
/* paper-item (two-line) */
|
||||
paper-item {
|
||||
paper-icon-item {
|
||||
position: relative;
|
||||
min-height: 32px;
|
||||
line-height: 32px;
|
||||
@@ -46,6 +46,8 @@
|
||||
--paper-item-focused-before: {
|
||||
opacity: 0;
|
||||
};
|
||||
|
||||
--paper-item-icon-width: 32px;
|
||||
}
|
||||
paper-item-body[two-line] {
|
||||
min-height: 32px;
|
||||
@@ -54,6 +56,17 @@
|
||||
:host-context(body[data-editors]) paper-item-body[two-line] {
|
||||
min-height: 40px;
|
||||
}
|
||||
div[item-icon] {
|
||||
border: 1px solid var(--loot-plugin-item-index-border-color, var(--paper-grey-400));
|
||||
border-radius: 50%;
|
||||
color: var(--secondary-text-color);
|
||||
height: 24px;
|
||||
width: 24px;
|
||||
line-height: 24px;
|
||||
text-align: center;
|
||||
font-family: monospace;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
#primary,
|
||||
#secondary,
|
||||
#secondary iron-icon {
|
||||
@@ -94,8 +107,9 @@
|
||||
color: var(--accent-color);
|
||||
}
|
||||
</style>
|
||||
<paper-item>
|
||||
<paper-icon-item>
|
||||
<paper-ripple></paper-ripple>
|
||||
<div item-icon hidden$="[[!computeLoadOrderIndexText(loadOrderIndex)]]">[[computeLoadOrderIndexText(loadOrderIndex)]]</div>
|
||||
<paper-item-body two-line>
|
||||
<div id="primary"><content></content></div>
|
||||
<div id="secondary" secondary>
|
||||
@@ -110,13 +124,17 @@
|
||||
<iron-icon id="editorIsOpen" icon="create"></iron-icon>
|
||||
<iron-icon id="hasUserEdits" icon="account-circle" hidden$="[[!hasUserEdits]]"></iron-icon>
|
||||
</div>
|
||||
</paper-item>
|
||||
</paper-icon-item>
|
||||
</template>
|
||||
<script>
|
||||
'use strict';
|
||||
Polymer({ // eslint-disable-line new-cap, no-undef
|
||||
is: 'loot-plugin-item',
|
||||
properties: {
|
||||
loadOrderIndex: {
|
||||
type: Number,
|
||||
value: undefined,
|
||||
},
|
||||
priority: {
|
||||
type: String,
|
||||
value: '',
|
||||
@@ -142,6 +160,19 @@
|
||||
return '';
|
||||
},
|
||||
|
||||
computeLoadOrderIndexText(loadOrderIndex) {
|
||||
if (loadOrderIndex > -1) {
|
||||
const number = loadOrderIndex.toString(16);
|
||||
if (number.length === 1) {
|
||||
return `0${number}`;
|
||||
}
|
||||
|
||||
return number;
|
||||
}
|
||||
|
||||
return '';
|
||||
},
|
||||
|
||||
getName() {
|
||||
return this.textContent.trim();
|
||||
},
|
||||
|
||||
@@ -160,6 +160,7 @@
|
||||
<template>
|
||||
<loot-plugin-item data-id$="[[item.id]]"
|
||||
data-index$="[[index]]"
|
||||
load-order-index="[[item.loadOrderIndex]]"
|
||||
priority="[[item.priority]]"
|
||||
is-priority-global="[[item.isPriorityGlobal]]"
|
||||
is-editor-open="[[item.isEditorOpen]]"
|
||||
|
||||
@@ -181,6 +181,7 @@
|
||||
this._messages = obj.messages || [];
|
||||
this._tags = obj.tags || [];
|
||||
this._isDirty = obj.isDirty || false;
|
||||
this.loadOrderIndex = obj.loadOrderIndex;
|
||||
|
||||
/* UI state variables */
|
||||
this.id = this.name.replace(/\s+/g, '');
|
||||
|
||||
@@ -970,6 +970,7 @@ YAML::Node QueryHandler::GenerateDerivedMetadata(const Plugin& file, const Plugi
|
||||
pluginNode["messages"] = tempPlugin.Messages();
|
||||
pluginNode["tags"] = tempPlugin.Tags();
|
||||
pluginNode["isDirty"] = isDirty;
|
||||
pluginNode["loadOrderIndex"] = lootState_.getCurrentGame().GetActiveLoadOrderIndex(tempPlugin.Name());
|
||||
|
||||
return pluginNode;
|
||||
}
|
||||
|
||||
@@ -317,6 +317,31 @@ TEST_P(GameTest, shouldShowBlankEspAsInactiveIfItHasBeenFullyLoadedAndTheGameHas
|
||||
|
||||
EXPECT_FALSE(game.IsPluginActive(blankEsp));
|
||||
}
|
||||
|
||||
TEST_P(GameTest, GetActiveLoadOrderIndexShouldReturnNegativeOneForAPluginThatIsNotActive) {
|
||||
Game game(GetParam());
|
||||
game.SetGamePath(dataPath.parent_path());
|
||||
ASSERT_NO_THROW(game.Init(false, localPath));
|
||||
|
||||
short index = game.GetActiveLoadOrderIndex(blankEsp);
|
||||
|
||||
EXPECT_EQ(-1, index);
|
||||
}
|
||||
|
||||
TEST_P(GameTest, GetActiveLoadOrderIndexShouldReturnTheLoadOrderIndexOmittingInactivePlugins) {
|
||||
Game game(GetParam());
|
||||
game.SetGamePath(dataPath.parent_path());
|
||||
ASSERT_NO_THROW(game.Init(false, localPath));
|
||||
|
||||
short index = game.GetActiveLoadOrderIndex(masterFile);
|
||||
EXPECT_EQ(0, index);
|
||||
|
||||
index = game.GetActiveLoadOrderIndex(blankEsm);
|
||||
EXPECT_EQ(1, index);
|
||||
|
||||
index = game.GetActiveLoadOrderIndex(blankDifferentMasterDependentEsp);
|
||||
EXPECT_EQ(2, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user