Skip to content

Commit

Permalink
The beginnings of the creature viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghostopheles committed May 7, 2024
1 parent c93ab77 commit 5307e61
Show file tree
Hide file tree
Showing 6 changed files with 192 additions and 6 deletions.
2 changes: 2 additions & 0 deletions Datamine/Datamine.toc
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,7 @@ Modules/Unified/Templates/MapViewer/MapPicker.lua
Modules/Unified/Templates/MapViewer/MapPicker.xml
Modules/Unified/Templates/MapViewer/MapViewer.lua
Modules/Unified/Templates/MapViewer/MapViewer.xml
Modules/Unified/Templates/CreatureView/CreatureView.lua
Modules/Unified/Templates/CreatureView/CreatureView.xml

Modules/Unified/Unified.xml
6 changes: 6 additions & 0 deletions Datamine/Localization/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ L["WORKSPACE_MODE_EXPLORER"] = "Explorer";
L["WORKSPACE_MODE_MOVIE"] = "Theater";
L["WORKSPACE_MODE_MAPS"] = "Maps";
L["WORKSPACE_MODE_STORAGE"] = "Storage";
L["WORKSPACE_MODE_CREATURES"] = "Creatures";

L["MODEL_CONTROLS_ALT_FORM_BUTTON_TOOLTIP_TEXT"] = "Toggle Alternate Form";

Expand Down Expand Up @@ -106,6 +107,11 @@ L["MAPVIEW_DETAILS_LABEL_WDT"] = "WDT";
L["MAPVIEW_DETAILS_GO"] = "Go";
L["MAPVIEW_DETAILS_DESC_TITLE"] = "Description";

L["CREATUREVIEW_LIST_TITLE"] = "Creatures";
L["CREATUREVIEW_LIST_SEARCH_FAIL_TEXT"] = "$Search Failed$";
L["CREATUREVIEW_TEXT_HELP_HEADER"] = "$Header$";
L["CREATUREVIEW_TEXT_HELP"] = "$Help$";

-- MODULES --

-- UI Main
Expand Down
78 changes: 78 additions & 0 deletions Datamine/Modules/Unified/Templates/CreatureView/CreatureView.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
local L = Datamine.Strings;
local Registry = Datamine.EventRegistry;
local Events = Datamine.Events;
local Popup = Datamine.Popup;
local Search = Datamine.Search;
local Database = Datamine.Database;

------------

DatamineCreaturePickerMixin = {};

function DatamineCreaturePickerMixin:OnLoad()
local titleBar = self.TitleBar;
local creatureList = self.CreatureList;

titleBar.TitleText:SetText(L.CREATUREVIEW_LIST_TITLE);
creatureList.Background_Base:Hide();

creatureList.HelpText:SetText(L.CREATUREVIEW_TEXT_HELP_HEADER);
creatureList.HelpTextDetails:SetText(L.CREATUREVIEW_TEXT_HELP);

creatureList:SetFailText(nil, L.CREATUREVIEW_LIST_SEARCH_FAIL_TEXT);

self:SetupSearchBox();
end

function DatamineCreaturePickerMixin:OnShow()
if self.SearchTask then
self.SearchTask:ClearSearchQuery();
end

if not self.Populated then
self:PopulateCreatures();
end

self.TitleBar.SearchBox:SetText("");
self.CreatureList.ScrollBox:ScrollToBegin();
end

function DatamineCreaturePickerMixin:SetupSearchBox()
local searchBox = self.TitleBar.SearchBox;
local creatureList = self.CreatureList;

creatureList:SetEditBox(searchBox);
end

function DatamineCreaturePickerMixin:PopulateCreatures()
local creatureList = self.CreatureList;

creatureList.HelpText:Hide();
creatureList.HelpTextDetails:Hide();

creatureList.ScrollView:SetPadding(2, 2, 2, 2, 2);

local allCreatures = {};
local creatures = Datamine.Database:GetAllCreatureEntries();
for creatureID, creatureInfo in pairs(creatures) do
local locale = GetLocale();
local data = {
ID = creatureID,
Text = creatureInfo.Name[locale],
TextScale = 0.9,
Callback = function() end,
BackgroundAlpha = 0.5,
};

tinsert(allCreatures, data);
end

local function AlphabeticalSort(a, b)
return a.Text < b.Text;
end

table.sort(allCreatures, AlphabeticalSort);
creatureList:SetSearchDataSource(allCreatures, "Text");

self.Populated = true;
end
94 changes: 94 additions & 0 deletions Datamine/Modules/Unified/Templates/CreatureView/CreatureView.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.blizzard.com/wow/ui/ https://raw.githubusercontent.com/Meorawr/wow-ui-schema/main/UI.xsd">

<Frame name="DatamineCreaturePickerTemplate" mixin="DatamineCreaturePickerMixin" virtual="true">
<Layers>
<Layer level="BACKGROUND">
<Texture parentKey="Background" inherits="DatamineMediumGrayBackgroundTemplate"
setAllPoints="true" />
</Layer>
</Layers>
<Frames>
<Frame parentKey="TitleBar">
<Size y="50" />
<Anchors>
<Anchor point="TOPLEFT" />
<Anchor point="TOPRIGHT" />
</Anchors>
<Layers>
<Layer level="ARTWORK">
<FontString parentKey="TitleText" font="DatamineCleanFontBig">
<Size x="125" />
<Anchors>
<Anchor point="TOP" />
<Anchor point="BOTTOM" relativePoint="CENTER" />
</Anchors>
</FontString>
</Layer>
</Layers>
<Frames>
<EditBox parentKey="SearchBox" inherits="DatamineEditBoxTemplate">
<Anchors>
<Anchor point="TOPLEFT" relativePoint="LEFT" x="10" />
<Anchor point="BOTTOMRIGHT" x="-4" />
</Anchors>
</EditBox>
</Frames>
</Frame>
<Frame parentKey="CreatureList" inherits="DatamineSearchableListTemplate">
<Anchors>
<Anchor point="TOPLEFT" relativeKey="$parent.TitleBar"
relativePoint="BOTTOMLEFT" x="6" y="-2" />
<Anchor point="BOTTOMRIGHT" x="-6" y="4" />
</Anchors>
<Layers>
<Layer level="ARTWORK">
<FontString parentKey="HelpText" font="DatamineCleanFont"
wordwrap="false"
justifyH="CENTER" justifyV="MIDDLE" text="TEXT HERE"
outline="THICK">
<Anchors>
<Anchor point="CENTER" y="20" />
</Anchors>
<Color r="0.45" g="0.45" b="0.45" a="1" />
</FontString>
<FontString parentKey="HelpTextDetails"
font="DatamineCleanFontSmall"
wordwrap="true"
maxLines="3"
justifyH="CENTER" justifyV="MIDDLE" text="DETAILS"
outline="THICK">
<Anchors>
<Anchor point="TOP" relativeKey="$parent.HelpText"
relativePoint="BOTTOM" y="-3" />
</Anchors>
<Color r="0.45" g="0.45" b="0.45" a="1" />
</FontString>
</Layer>
<Layer level="BACKGROUND">
<Texture parentKey="Background"
inherits="DatamineDarkGrayBackgroundTemplate"
setAllPoints="true" />
</Layer>
</Layers>
</Frame>
</Frames>
<Scripts>
<OnLoad method="OnLoad" />
<OnShow method="OnShow" />
</Scripts>
</Frame>

<Frame name="DatamineCreatureViewTabTemplate" virtual="true">
<Frames>
<Frame parentKey="CreaturePicker" inherits="DatamineCreaturePickerTemplate"
frameLevel="5">
<Size x="300" />
<Anchors>
<Anchor point="TOPLEFT" x="4" y="-4" />
<Anchor point="BOTTOMLEFT" x="4" y="4" />
</Anchors>
</Frame>
</Frames>
</Frame>
</Ui>
3 changes: 3 additions & 0 deletions Datamine/Modules/Unified/Unified.xml
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,9 @@
hidden="true" />
<Frame parentKey="MapViewTab" inherits="DatamineMapViewerTemplate" setAllPoints="true"
hidden="true" />
<Frame parentKey="CreatureViewTab" inherits="DatamineCreatureViewTabTemplate"
setAllPoints="true"
hidden="true" />
</Frames>
<Layers>
<Layer level="BACKGROUND">
Expand Down
15 changes: 9 additions & 6 deletions Datamine/Modules/Unified/UnifiedUIMixins.lua
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,7 @@ DatamineWorkspaceMixin.Modes = {
STORAGE = 3,
MOVIE = 4,
MAPS = 5,
CREATURE = 6,
};

function DatamineWorkspaceMixin:OnLoad()
Expand All @@ -891,6 +892,9 @@ function DatamineWorkspaceMixin:OnLoad()
[self.Modes.STORAGE] = {
self.StorageTab,
},
[self.Modes.CREATURE] = {
self.CreatureViewTab,
},
};

Registry:RegisterCallback(Events.WORKSPACE_MODE_CHANGED, self.OnModeChanged, self);
Expand All @@ -915,12 +919,11 @@ function DatamineWorkspaceMixin:OnLoad()
toolbar:AddButton("custom-toolbar-scale", cb, tooltipText);
end

-- temporarily disabling this because it is an utter abomination and deserves to be thrown into a meat grinder
--do
-- local tooltipText = L.WORKSPACE_MODE_STORAGE;
-- local cb = function() self:SetMode(self.Modes.STORAGE); end;
-- toolbar:AddButton("custom-toolbar-scale", cb, tooltipText);
--end
do
local tooltipText = L.WORKSPACE_MODE_STORAGE;
local cb = function() self:SetMode(self.Modes.CREATURE); end;
toolbar:AddButton("custom-toolbar-scale", cb, tooltipText);
end
end

function DatamineWorkspaceMixin:OnModeChanged()
Expand Down

0 comments on commit 5307e61

Please sign in to comment.