Przeglądaj źródła

improved ui buttons

Kolja Strohm 2 lat temu
rodzic
commit
a45903ce8f

+ 18 - 51
FactoryCraft/Chat.cpp

@@ -1,25 +1,19 @@
 #include "Chat.h"
 
+#include <AsynchronCall.h>
 #include <DateiSystem.h>
 
+#include "ChatMessage.h"
 #include "Game.h"
 #include "Globals.h"
-#include "ChatMessage.h"
-#include <AsynchronCall.h>
 
 Chat::Chat()
-    : Fenster(),
+    : OptionsWindow([this]() { options->addStyle(Fenster::Style::Sichtbar); }),
       optionsAdded(0)
 {
-    setStyle(
-        Fenster::Style::Erlaubt
-        | Fenster::Style::Rahmen | Fenster::Style::BodyHAlpha
-        | Fenster::Style::Titel
-        | Fenster::Style::TitelHAlpha | Fenster::Style::Closable
-        | Fenster::Style::ClosingHAlpha | Fenster::Style::ClosingKlickBuffer
-        | Fenster::Style::TitelHintergrund | Fenster::Style::BodyHintergrund
-        | Fenster::Style::ClosingHintergrund | Fenster::Style::MEIgnoreInside | Fenster::Style::HeightChangeable | Fenster::Style::BreiteChangeable | Fenster::Style::BodyMinBr | Fenster::Style::BodyMinHi | Fenster::Style::LeftPositionFixed | Fenster::Style::BottomPositionFixed);
-    removeStyle(Fenster::Style::Sichtbar);
+    addStyle( Fenster::Style::LeftPositionFixed
+        | Fenster::Style::BottomPositionFixed);
+    removeStyle(Fenster::Style::Beweglich);
     setTitel("Chat");
     setClosingMe([this](void* p, void* o, Framework::MausEreignis me) {
         if (me.id == Framework::ME_RLinks)
@@ -31,17 +25,6 @@ Chat::Chat()
     });
     setSize(500, 300);
     setPosition(5, uiFactory.initParam.bildschirm->getBackBufferSize().y - 305);
-    setMausEreignis(Framework::_ret1ME);
-    setTastaturEreignis(Framework::_ret1TE);
-    setRBreite(1);
-    setRFarbe(0xFF52525E);
-    setKBgFarbe(0xA0000000);
-    setTBgFarbe(0xA0000000);
-    setSBgFarbe(0xA0000000);
-    setTSchriftZ(
-        dynamic_cast<Schrift*>(uiFactory.initParam.schrift->getThis()));
-    zTTextFeld()->setSize(0, 20);
-    zTTextFeld()->addStyle(TextFeld::Style::Center);
     setKMin(200, 100);
 
     options = new ChatOptions();
@@ -52,8 +35,8 @@ Chat::Chat()
 
     commandLine = uiFactory.createTextFeld(uiFactory.initParam);
     commandLine->setText("");
-    commandLine->setSize(getInnenBreite() - 40, 20);
-    commandLine->setPosition(20, getInnenHeight() - 20);
+    commandLine->setSize(getInnenBreite() - 20, 20);
+    commandLine->setPosition(0, getInnenHeight() - 20);
     commandLine->setStyle(Framework::TextFeld::Style::TextFeld);
     commandLine->setTastaturEreignis(
         [this](void* p, void* o, Framework::TastaturEreignis te) {
@@ -105,27 +88,6 @@ Chat::Chat()
             return 1;
         });
     addMember(sendButton);
-
-    optionsButton = uiFactory.createKnopf(uiFactory.initParam);
-    optionsButton->setAlphaFeldFarbe(0x5F337AB7);
-    optionsButton->setToolTipText(
-        "Options", uiFactory.initParam.bildschirm, uiFactory.initParam.schrift);
-    optionsButton->setSize(20, 20);
-    optionsButton->setPosition(0, getInnenHeight() - 20);
-    optionsButton->addStyle(Framework::Knopf::Style::HBild
-                            | Framework::Knopf::Style::HAlpha
-                            | Framework::Knopf::Style::Hintergrund);
-    optionsButton->setHintergrundBildZ(
-        iconsDat.laden(0, new Text("options.png")));
-    optionsButton->setMausEreignis(
-        [this](void* p, void* o, Framework::MausEreignis me) {
-            if (me.id == ME_RLinks)
-            {
-                options->addStyle(Fenster::Style::Sichtbar);
-            }
-            return 1;
-        });
-    addMember(optionsButton);
 }
 
 Chat ::~Chat()
@@ -148,12 +110,17 @@ bool Chat::tick(double time)
     if (!optionsAdded)
     {
         optionsAdded = 1;
-        uiFactory.initParam.bildschirm->addMember(dynamic_cast<Zeichnung*>(options->getThis()));
+        uiFactory.initParam.bildschirm->addMember(
+            dynamic_cast<Zeichnung*>(options->getThis()));
     }
+    return OptionsWindow::tick(time);
+}
+
+void Chat::render(Framework::Bild& rObj)
+{
     history->setSize(getInnenBreite(), getInnenHeight() - 20);
-    commandLine->setSize(getInnenBreite() - 40, 20);
-    commandLine->setPosition(20, getInnenHeight() - 20);
+    commandLine->setSize(getInnenBreite() - 20, 20);
+    commandLine->setPosition(0, getInnenHeight() - 20);
     sendButton->setPosition(getInnenBreite() - 20, getInnenHeight() - 20);
-    optionsButton->setPosition(0, getInnenHeight() - 20);
-    return Fenster::tick(time);
+    OptionsWindow::render(rObj);
 }

+ 3 - 3
FactoryCraft/Chat.h

@@ -1,19 +1,18 @@
 #pragma once
 
-#include <Fenster.h>
+#include "OptionsWindow.h"
 #include <TextFeld.h>
 #include <Knopf.h>
 
 #include "ChatHistory.h"
 #include "ChatOptions.h"
 
-class Chat : public Framework::Fenster
+class Chat : public OptionsWindow
 {
 private:
     ChatHistory* history;
     Framework::TextFeld* commandLine;
     Framework::Knopf* sendButton;
-    Framework::Knopf* optionsButton;
     ChatOptions* options;
     bool optionsAdded;
     
@@ -24,4 +23,5 @@ public:
     void addMessage(char* data);
     void initOptions(char* data);
     bool tick(double time) override;
+    void render(Framework::Bild& rObj) override;
 };

+ 14 - 7
FactoryCraft/ChatOptions.cpp

@@ -8,6 +8,10 @@
 ChatOptions::ChatOptions()
     : Fenster()
 {
+    LTDBDatei iconsDat;
+    iconsDat.setDatei(new Text("data/bilder/gui_icons.ltdb"));
+    iconsDat.leseDaten(0);
+    
     setStyle(
         Fenster::Style::Erlaubt | Fenster::Style::Rahmen
         | Fenster::Style::BodyHAlpha | Fenster::Style::Titel
@@ -15,7 +19,8 @@ ChatOptions::ChatOptions()
         | Fenster::Style::ClosingHAlpha | Fenster::Style::ClosingKlickBuffer
         | Fenster::Style::TitelHintergrund | Fenster::Style::BodyHintergrund
         | Fenster::Style::ClosingHintergrund | Fenster::Style::MEIgnoreInside
-        | Fenster::Style::Beweglich);
+        | Fenster::Style::Beweglich | Style::ClosingHBild
+        | Style::ClosingBuffer);
     removeStyle(Fenster::Style::Sichtbar);
     setTitel("Chat options");
     setClosingMe([this](void* p, void* o, Framework::MausEreignis me) {
@@ -38,6 +43,11 @@ ChatOptions::ChatOptions()
         dynamic_cast<Schrift*>(uiFactory.initParam.schrift->getThis()));
     zTTextFeld()->setSize(0, 20);
     zTTextFeld()->addStyle(TextFeld::Style::Center);
+    setSAfStrength(10);
+    setSAfFarbe(0x5F9C0A0A);
+    setSBgBildZ(iconsDat.laden(0, new Text("close.png")));
+    setSKAfFarbe(0xFF9C0A0A);
+    setSKAfStrength(10);
 
     infoChannel = initKontrollKnopf(5,
         5,
@@ -107,12 +117,9 @@ ChatOptions::ChatOptions()
         Framework::TextFeld::Style::Text | Framework::TextFeld::Style::VCenter,
         "Ignored players:");
     addMember(blackListLabel);
-
-    LTDBDatei dat;
-    dat.setDatei(new Text("data/bilder/gui_icons.ltdb"));
-    dat.leseDaten(0);
-    plus = dat.laden(0, new Text("plus.png"));
-    trash = dat.laden(0, new Text("trash.png"));
+    
+    plus = iconsDat.laden(0, new Text("plus.png"));
+    trash = iconsDat.laden(0, new Text("trash.png"));
 
     playerName = initTextFeld(
         5, 115, 225, 20, Framework::TextFeld::Style::TextFeld, "");

+ 71 - 52
FactoryCraft/Dialog.cpp

@@ -1,86 +1,105 @@
-#include <XML.h>
-#include <TextFeld.h>
+#include "Dialog.h"
+
+#include <DateiSystem.h>
 #include <TastaturEreignis.h>
+#include <TextFeld.h>
+#include <XML.h>
 
-#include "Dialog.h"
-#include "InventoryView.h"
-#include "Equipment.h"
 #include "CraftingGrid.h"
 #include "CraftingRecipies.h"
+#include "Equipment.h"
+#include "Globals.h"
+#include "InventoryView.h"
 #include "RecipieIngredient.h"
 #include "RecipieOutput.h"
 #include "ShapedRecipie.h"
 #include "UnshapedRecipie.h"
-#include "Globals.h"
 
 using namespace Framework;
 
-UIMLDialog::UIMLDialog(Framework::Text uiml, std::function<void(UIMLDialog* self)> onClose)
-	: Fenster()
+UIMLDialog::UIMLDialog(
+    Framework::Text uiml, std::function<void(UIMLDialog* self)> onClose)
+    : Fenster()
 {
-	XML::Element* xml = new XML::Element(uiml);
-	view = new UIMLView("<v/>", uiFactory);
-	view->setStyle(UIMLView::Style::Erlaubt | UIMLView::Style::Sichtbar);
-	view->setMausEreignis(_ret1ME);
-	view->addKnownElement(new InventoryElement());
-	view->addKnownElement(new EquipmentElement());
-	view->addKnownElement(new CraftingGridElement());
+    XML::Element* xml = new XML::Element(uiml);
+    view = new UIMLView("<v/>", uiFactory);
+    view->setStyle(UIMLView::Style::Erlaubt | UIMLView::Style::Sichtbar);
+    view->setMausEreignis(_ret1ME);
+    view->addKnownElement(new InventoryElement());
+    view->addKnownElement(new EquipmentElement());
+    view->addKnownElement(new CraftingGridElement());
     view->addKnownElement(new CraftingRecipiesElement());
     view->addKnownElement(new RecipieIngredientElement());
     view->addKnownElement(new RecipieOutputElement());
     view->addKnownElement(new ShapedRecipieElement());
     view->addKnownElement(new UnshapedRecipieElement());
-	view->setUIML(xml);
-	view->setSize((int)xml->getAttributeValue("width"), (int)xml->getAttributeValue("height"));
-	name = xml->getAttributeValue("id");
-	view->layout();
-	if (!xml->hasAttribute("width"))
-	{
+    view->setUIML(xml);
+    view->setSize((int)xml->getAttributeValue("width"),
+        (int)xml->getAttributeValue("height"));
+    name = xml->getAttributeValue("id");
+    view->layout();
+    if (!xml->hasAttribute("width"))
+    {
         view->setSize(view->calculateContentSize().x, view->getHeight());
     }
     if (!xml->hasAttribute("height"))
     {
         view->setSize(view->getBreite(), view->calculateContentSize().y);
     }
-	addMember(view);
+    addMember(view);
+
+    LTDBDatei iconsDat;
+    iconsDat.setDatei(new Text("data/bilder/gui_icons.ltdb"));
+    iconsDat.leseDaten(0);
 
-	setStyle(Fenster::Style::Sichtbar | Fenster::Style::Erlaubt | Fenster::Style::Rahmen | Fenster::Style::BodyHAlpha | Fenster::Style::Beweglich | Fenster::Style::Titel | Fenster::Style::TitelHAlpha | Fenster::Style::Closable | Fenster::Style::ClosingHAlpha | Fenster::Style::ClosingKlickBuffer | Fenster::Style::TitelHintergrund | Fenster::Style::BodyHintergrund | Fenster::Style::ClosingHintergrund | Fenster::Style::MEIgnoreInside);
-	setKBgFarbe(0xA0000000);
-	setTBgFarbe(0xA0000000);
-	setSBgFarbe(0xA0000000);
-	setSize(view->getBreite() + 4, view->getHeight() + 24);
-	setPosition(window->zBildschirm()->getBackBufferSize() / 2 - getSize() / 2);
-	setRBreite(2);
-	setClosingMe([onClose, this](void* p, void* o, MausEreignis me)
-		{
-			if (me.id == ME_RLinks)
-				onClose(this);
-			return 1;
-		});
-	setRFarbe(0xFF52525E);
-	setTitel(xml->getAttributeValue("title"));
-	setTSchriftZ(dynamic_cast<Schrift*>(uiFactory.initParam.schrift->getThis()));
-	zTTextFeld()->setSize(0, 20);
-	zTTextFeld()->addStyle(TextFeld::Style::Center);
-	setTastaturEreignis(_ret1TE);
+    setStyle(
+        Fenster::Style::Sichtbar | Fenster::Style::Erlaubt
+        | Fenster::Style::Rahmen | Fenster::Style::BodyHAlpha
+        | Fenster::Style::Beweglich | Fenster::Style::Titel
+        | Fenster::Style::TitelHAlpha | Fenster::Style::Closable
+        | Fenster::Style::ClosingHAlpha | Fenster::Style::ClosingKlickBuffer
+        | Fenster::Style::TitelHintergrund | Fenster::Style::BodyHintergrund
+        | Fenster::Style::ClosingHintergrund | Fenster::Style::MEIgnoreInside
+        | Style::ClosingBuffer | Style::ClosingHBild);
+    setKBgFarbe(0xA0000000);
+    setTBgFarbe(0xA0000000);
+    setSBgFarbe(0xA0000000);
+    setSize(view->getBreite() + 4, view->getHeight() + 24);
+    setPosition(window->zBildschirm()->getBackBufferSize() / 2 - getSize() / 2);
+    setRBreite(2);
+    setClosingMe([onClose, this](void* p, void* o, MausEreignis me) {
+        if (me.id == ME_RLinks) onClose(this);
+        return 1;
+    });
+    setRFarbe(0xFF52525E);
+    setTitel(xml->getAttributeValue("title"));
+    setTSchriftZ(
+        dynamic_cast<Schrift*>(uiFactory.initParam.schrift->getThis()));
+    zTTextFeld()->setSize(0, 20);
+    zTTextFeld()->addStyle(TextFeld::Style::Center);
+    setTastaturEreignis(_ret1TE);
+    setSAfStrength(10);
+    setSAfFarbe(0x5F9C0A0A);
+    setSBgBildZ(iconsDat.laden(0, new Text("close.png")));
+    setSKAfFarbe(0xFF9C0A0A);
+    setSKAfStrength(10);
 }
 
-UIMLDialog::~UIMLDialog()
-{}
+UIMLDialog::~UIMLDialog() {}
 
 void UIMLDialog::api(char* message)
 {
-	short idLen = *(short*)message;
-	char* id = new char[idLen + 1];
-	memcpy(id, message + 2, idLen);
-	id[idLen] = 0;
-	NetworkAPIProcessor* processor = dynamic_cast<NetworkAPIProcessor*>(view->zZeichnungById(id));
-	if (processor)
-		processor->api(message + 2 + idLen);
-	delete[] id;
+    short idLen = *(short*)message;
+    char* id = new char[idLen + 1];
+    memcpy(id, message + 2, idLen);
+    id[idLen] = 0;
+    NetworkAPIProcessor* processor
+        = dynamic_cast<NetworkAPIProcessor*>(view->zZeichnungById(id));
+    if (processor) processor->api(message + 2 + idLen);
+    delete[] id;
 }
 
 const Framework::Text& UIMLDialog::getName() const
 {
-	return name;
+    return name;
 }

+ 4 - 0
FactoryCraft/FactoryCraft.vcxproj

@@ -202,7 +202,9 @@ copy "..\..\..\..\..\Allgemein\Network\x64\Release\Network.dll" "network.dll"</C
     <ClCompile Include="ItemList.cpp" />
     <ClCompile Include="ItemType.cpp" />
     <ClCompile Include="Load.cpp" />
+    <ClCompile Include="MapOptions.cpp" />
     <ClCompile Include="MapWindow.cpp" />
+    <ClCompile Include="OptionsWindow.cpp" />
     <ClCompile Include="RecipieGroup.cpp" />
     <ClCompile Include="RecipieIngredient.cpp" />
     <ClCompile Include="RecipieOutput.cpp" />
@@ -253,7 +255,9 @@ copy "..\..\..\..\..\Allgemein\Network\x64\Release\Network.dll" "network.dll"</C
     <ClInclude Include="ItemList.h" />
     <ClInclude Include="ItemType.h" />
     <ClInclude Include="Load.h" />
+    <ClInclude Include="MapOptions.h" />
     <ClInclude Include="MapWindow.h" />
+    <ClInclude Include="OptionsWindow.h" />
     <ClInclude Include="RecipieGroup.h" />
     <ClInclude Include="RecipieIngredient.h" />
     <ClInclude Include="RecipieOutput.h" />

+ 15 - 0
FactoryCraft/FactoryCraft.vcxproj.filters

@@ -59,6 +59,9 @@
     <Filter Include="Menu\map">
       <UniqueIdentifier>{775b26b6-17cd-4eca-9360-a1a2965ea0eb}</UniqueIdentifier>
     </Filter>
+    <Filter Include="Menu\utils">
+      <UniqueIdentifier>{85fd0935-ea54-491e-bd78-f6547890cfca}</UniqueIdentifier>
+    </Filter>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Main.cpp">
@@ -202,6 +205,12 @@
     <ClCompile Include="MapWindow.cpp">
       <Filter>Menu\map</Filter>
     </ClCompile>
+    <ClCompile Include="MapOptions.cpp">
+      <Filter>Menu\map</Filter>
+    </ClCompile>
+    <ClCompile Include="OptionsWindow.cpp">
+      <Filter>Menu\utils</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="Area.h">
@@ -351,6 +360,12 @@
     <ClInclude Include="MapWindow.h">
       <Filter>Menu\map</Filter>
     </ClInclude>
+    <ClInclude Include="MapOptions.h">
+      <Filter>Menu\map</Filter>
+    </ClInclude>
+    <ClInclude Include="OptionsWindow.h">
+      <Filter>Menu\utils</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <FxCompile Include="DX11CustomVertexShader.hlsl">

+ 16 - 5
FactoryCraft/ItemList.cpp

@@ -1,10 +1,11 @@
 #include "ItemList.h"
 
+#include <DateiSystem.h>
 #include <Scroll.h>
 #include <TextFeld.h>
 
-#include "Globals.h"
 #include "Game.h"
+#include "Globals.h"
 #include "UIMLToolTip.h"
 #include "World.h"
 
@@ -63,7 +64,8 @@ int ItemList::getSlotByLocalPos(Framework::Punkt pos)
     return -1;
 }
 
-void ItemList::doMausEreignis(Framework::MausEreignis& me, bool userRet) {
+void ItemList::doMausEreignis(Framework::MausEreignis& me, bool userRet)
+{
     mausPos.x = me.originalX;
     mausPos.y = me.originalY;
     if (me.id == ME_Bewegung)
@@ -105,8 +107,7 @@ void ItemList::adjustSize(int parentWidth, int parentHeight)
         ipr = 1;
     }
     setSize(ipr * 60 - 10,
-        (itemTypeCount / ipr + (itemTypeCount % ipr == 0 ? 0 : 1)) * 60
-            - 10);
+        (itemTypeCount / ipr + (itemTypeCount % ipr == 0 ? 0 : 1)) * 60 - 10);
 }
 
 void ItemList::render(Framework::Bild& rObj)
@@ -143,6 +144,10 @@ void ItemList::render(Framework::Bild& rObj)
 ItemListContainer::ItemListContainer()
     : Fenster()
 {
+    LTDBDatei iconsDat;
+    iconsDat.setDatei(new Text("data/bilder/gui_icons.ltdb"));
+    iconsDat.leseDaten(0);
+
     setStyle(
         Fenster::Style::Erlaubt | Fenster::Style::Rahmen
         | Fenster::Style::BodyHAlpha | Fenster::Style::Beweglich
@@ -153,7 +158,8 @@ ItemListContainer::ItemListContainer()
         | Fenster::Style::BodyMinHi | Fenster::Style::HeightChangeable
         | Fenster::Style::Closable | Fenster::Style::ClosingHAlpha
         | Fenster::Style::ClosingKlickBuffer | Fenster::Style::ClosingHAlpha
-        | Fenster::Style::ClosingHintergrund);
+        | Fenster::Style::ClosingHintergrund | Style::ClosingHBild
+        | Style::ClosingBuffer);
     setKBgFarbe(0xA0000000);
     setTBgFarbe(0xA0000000);
     setSBgFarbe(0xA0000000);
@@ -175,6 +181,11 @@ ItemListContainer::ItemListContainer()
         if (me.id == ME_RLinks) removeStyle(Style::Sichtbar);
         return 1;
     });
+    setSAfStrength(10);
+    setSAfFarbe(0x5F9C0A0A);
+    setSBgBildZ(iconsDat.laden(0, new Text("close.png")));
+    setSKAfFarbe(0xFF9C0A0A);
+    setSKAfStrength(10);
 
     list = new ItemList();
     list->setPosition(10, 10);

+ 0 - 0
FactoryCraft/MapOptions.cpp


+ 1 - 0
FactoryCraft/MapOptions.h

@@ -0,0 +1 @@
+#pragma once

+ 4 - 24
FactoryCraft/MapWindow.cpp

@@ -5,20 +5,11 @@
 #include "Globals.h"
 
 MapWindow::MapWindow()
-    : Fenster(),
+    : OptionsWindow([this]() {
+          // TODO: open options
+      }),
       map(0)
 {
-    setStyle(
-        Fenster::Style::Erlaubt | Fenster::Style::Rahmen
-        | Fenster::Style::BodyHAlpha | Fenster::Style::Titel
-        | Fenster::Style::TitelHAlpha | Fenster::Style::Closable
-        | Fenster::Style::ClosingHAlpha | Fenster::Style::ClosingKlickBuffer
-        | Fenster::Style::TitelHintergrund | Fenster::Style::BodyHintergrund
-        | Fenster::Style::ClosingHintergrund | Fenster::Style::MEIgnoreInside
-        | Fenster::Style::HeightChangeable | Fenster::Style::BreiteChangeable
-        | Fenster::Style::BodyMinBr | Fenster::Style::BodyMinHi
-        | Fenster::Style::Beweglich);
-    removeStyle(Fenster::Style::Sichtbar);
     setTitel("Map");
     setClosingMe([this](void* p, void* o, Framework::MausEreignis me) {
         if (me.id == Framework::ME_RLinks)
@@ -32,17 +23,6 @@ MapWindow::MapWindow()
                     - getBreite() / 2,
         uiFactory.initParam.bildschirm->getBackBufferSize().y / 2
             - getHeight() / 2);
-    setMausEreignis(Framework::_ret1ME);
-    setTastaturEreignis(Framework::_ret1TE);
-    setRBreite(1);
-    setRFarbe(0xFF52525E);
-    setKBgFarbe(0xA0000000);
-    setTBgFarbe(0xA0000000);
-    setSBgFarbe(0xA0000000);
-    setTSchriftZ(
-        dynamic_cast<Schrift*>(uiFactory.initParam.schrift->getThis()));
-    zTTextFeld()->setSize(0, 20);
-    zTTextFeld()->addStyle(TextFeld::Style::Center);
     setKMin(200, 200);
 }
 
@@ -89,5 +69,5 @@ void MapWindow::addChunk(ChunkMap* chunk)
 bool MapWindow::tick(double time)
 {
     if (map) map->setSize(getInnenBreite(), getInnenHeight());
-    return Fenster::tick(time);
+    return OptionsWindow::tick(time);
 }

+ 2 - 2
FactoryCraft/MapWindow.h

@@ -1,10 +1,10 @@
 #pragma once
 
-#include <Fenster.h>
+#include "OptionsWindow.h"
 
 #include "DimensionMap.h"
 
-class MapWindow : public Framework::Fenster
+class MapWindow : public OptionsWindow
 {
 private:
     DimensionMap* map;

+ 98 - 0
FactoryCraft/OptionsWindow.cpp

@@ -0,0 +1,98 @@
+#include "OptionsWindow.h"
+
+#include <DateiSystem.h>
+
+#include "Globals.h"
+#include "Initialisierung.h"
+
+OptionsWindow::OptionsWindow(std::function<void()> onOptionsOpen)
+    : Fenster(),
+      onOptionsOpen(onOptionsOpen)
+{
+    LTDBDatei iconsDat;
+    iconsDat.setDatei(new Text("data/bilder/gui_icons.ltdb"));
+    iconsDat.leseDaten(0);
+
+    setStyle(Style::Erlaubt | Style::Rahmen | Style::BodyHAlpha | Style::Titel
+             | Style::TitelHAlpha | Style::Closable | Style::ClosingHAlpha
+             | Style::CustomTitle | Style::ClosingBuffer
+             | Style::ClosingKlickBuffer | Style::ClosingHBild
+             | Style::TitelHintergrund | Style::BodyHintergrund
+             | Style::ClosingHintergrund | Style::MEIgnoreInside
+             | Style::HeightChangeable | Style::BreiteChangeable
+             | Style::BodyMinBr | Style::BodyMinHi | Style::Beweglich);
+    removeStyle(Style::Sichtbar);
+    setMausEreignis(Framework::_ret1ME);
+    setTastaturEreignis(Framework::_ret1TE);
+    setRBreite(1);
+    setRFarbe(0xFF52525E);
+    setKBgFarbe(0xA0000000);
+    setTBgFarbe(0xA0000000);
+    setSBgFarbe(0xA0000000);
+    setTSchriftZ(
+        dynamic_cast<Schrift*>(uiFactory.initParam.schrift->getThis()));
+    zTTextFeld()->setSize(0, 20);
+    zTTextFeld()->addStyle(TextFeld::Style::Center);
+    setSAfStrength(10);
+    setSAfFarbe(0x5F9C0A0A);
+    setSBgBildZ(iconsDat.laden(0, new Text("close.png")));
+    setSKAfFarbe(0xFF9C0A0A);
+    setSKAfStrength(10);
+
+    optionsButton = initKnopf(0,
+        0,
+        20,
+        20,
+        Framework::Knopf::Style::HBild | Framework::Knopf::Style::HAlpha
+            | Framework::Knopf::Style::Hintergrund,
+        "");
+    optionsButton->setAlphaFeldFarbe(0x5F337AB7);
+    optionsButton->setToolTipText(
+        "Options", uiFactory.initParam.bildschirm, uiFactory.initParam.schrift);
+    optionsButton->setHintergrundBildZ(
+        iconsDat.laden(0, new Text("options.png")));
+    optionsButton->setMausEreignis([this](void* p, void* o, MausEreignis me) {
+        if (me.id == ME_RLinks)
+        {
+            this->onOptionsOpen();
+        }
+        return 1;
+    });
+}
+
+OptionsWindow::~OptionsWindow()
+{
+    optionsButton->release();
+}
+
+void OptionsWindow::doMausEreignis(Framework::MausEreignis& me, bool userRet)
+{
+    optionsButton->doPublicMausEreignis(me);
+    Fenster::doMausEreignis(me, userRet);
+}
+
+bool OptionsWindow::tick(double time)
+{
+    rend |= optionsButton->tick(time);
+    return Fenster::tick(time);
+}
+
+void OptionsWindow::render(Framework::Bild& rObj)
+{
+    if (!hatStyle(Style::Sichtbar)) return;
+    int titleHeight = zTTextFeld()->getHeight();
+    zTTextFeld()->setPosition(titleHeight, 0);
+    int closingWidth = 0;
+    if (hatStyle(Style::Closable)) closingWidth = titleHeight;
+    zTTextFeld()->setWidth(getInnenBreite() - titleHeight - closingWidth);
+    Fenster::render(rObj);
+    optionsButton->setSize(titleHeight, titleHeight);
+    int rbr = getRBreite();
+    if (!rObj.setDrawOptions(
+            pos.x + rbr, pos.y + rbr, gr.x - rbr * 2, titleHeight))
+    {
+        return;
+    }
+    optionsButton->render(rObj);
+    rObj.releaseDrawOptions();
+}

+ 19 - 0
FactoryCraft/OptionsWindow.h

@@ -0,0 +1,19 @@
+#pragma once
+
+#include <Fenster.h>
+#include <Knopf.h>
+
+class OptionsWindow : public Framework::Fenster
+{
+private:
+    std::function<void()> onOptionsOpen;
+    Framework::Knopf* optionsButton;
+    
+public:
+    OptionsWindow(std::function<void()> onOptionsOpen);
+    ~OptionsWindow();
+
+    virtual void doMausEreignis(Framework::MausEreignis& me, bool userRet) override;
+    virtual bool tick(double time) override;
+    virtual void render(Framework::Bild& rObj) override;
+};

+ 36 - 47
FactoryCraft/ServerSelection.cpp

@@ -5,6 +5,7 @@
 #include <Base64.h>
 #include <Bild.h>
 #include <Datei.h>
+#include <DateiSystem.h>
 #include <JSON.h>
 #include <Knopf.h>
 #include <Schrift.h>
@@ -31,11 +32,8 @@ ServerStatus::ServerStatus(Framework::Text name,
       statusId(0),
       requestId(0),
       secrets(secrets),
-      closeAF(new AlphaFeld()),
       join(initKnopf(0, 0, 55, 20, Knopf::Style::Normal, "join"))
 {
-    closeAF->setSize(20, 20);
-    closeAF->setFarbe(0x00FF0000);
     setMausEreignis(_ret1ME);
     setStyle(Style::Erlaubt | Style::Sichtbar | Style::Rahmen);
     setRahmenBreite(1);
@@ -96,12 +94,39 @@ ServerStatus::ServerStatus(Framework::Text name,
         }
         return 1;
     });
+
+    LTDBDatei iconsDat;
+    iconsDat.setDatei(new Text("data/bilder/gui_icons.ltdb"));
+    iconsDat.leseDaten(0);
+
+    removeButton = initKnopf(0,
+        0,
+        20,
+        20,
+        Framework::Knopf::Style::HBild | Framework::Knopf::Style::HAlpha
+            | Framework::Knopf::Style::Hintergrund,
+        "");
+    removeButton->setRahmenFarbe(0xFF9C0A0A);
+    removeButton->setAlphaFeldFarbe(0x5F9C0A0A);
+    removeButton->setToolTipText("Remove player from list of ignored players",
+        uiFactory.initParam.bildschirm,
+        uiFactory.initParam.schrift);
+    removeButton->setHintergrundBildZ(
+        dynamic_cast<Bild*>(iconsDat.laden(0, new Text("trash.png"))));
+    removeButton->setMausEreignis([this](void* p, void* o, MausEreignis me) {
+        if (me.id == ME_RLinks)
+        {
+            ((ServerSelectionMenu*)(Menu*)menuRegister->get("serverSelection"))
+                ->removeServer(this->name);
+        }
+        return 1;
+    });
 }
 
 ServerStatus::~ServerStatus()
 {
     secrets->release();
-    closeAF->release();
+    removeButton->release();
     join->release();
 }
 
@@ -141,8 +166,7 @@ void ServerStatus::updatePlayerName(Framework::Text playerName)
                 if (statusId == 403)
                 {
                     int secondStatus = client->status(tmp->playerName, "");
-                    if (secondStatus == 200)
-                        statusId = 203;
+                    if (secondStatus == 200) statusId = 203;
                 }
                 if (secret.istGleich("") && statusId == 200)
                 {
@@ -155,8 +179,7 @@ void ServerStatus::updatePlayerName(Framework::Text playerName)
                     tmp->statusId = statusId;
                     if (tmp->statusId == 200)
                         tmp->status = "The Server is reachable";
-                    if (statusId == 203)
-                        tmp->status = "Create a new player";
+                    if (statusId == 203) tmp->status = "Create a new player";
                     if (tmp->statusId == 403)
                         tmp->status = "The name is already in use";
                     tmp->rend = 1;
@@ -171,48 +194,16 @@ void ServerStatus::updatePlayerName(Framework::Text playerName)
 
 void ServerStatus::doMausEreignis(Framework::MausEreignis& me, bool userRet)
 {
-    if (me.id == ME_Leaves)
-    {
-        closeAF->setStrength(0);
-        closeAF->setFarbe(0x00FF0000);
-    }
-    else if (me.id == ME_Bewegung)
-    {
-        if (me.mx >= gr.x - 20 && me.mx < gr.x && me.my >= 0 && me.my <= 20)
-        {
-            if (closeAF->getStrength() == 0)
-            {
-                closeAF->setStrength(-5);
-                closeAF->setFarbe(0x30FF0000);
-            }
-        }
-        else
-        {
-            if (closeAF->getStrength() != 0)
-            {
-                closeAF->setStrength(0);
-                closeAF->setFarbe(0x00FF0000);
-            }
-        }
-    }
-    if (me.id == ME_RLinks)
-    {
-        if (me.mx >= gr.x - 20 && me.mx < gr.x && me.my >= 0 && me.my <= 20)
-        {
-            ((ServerSelectionMenu*)(Menu*)menuRegister->get("serverSelection"))
-                ->removeServer(name);
-            return;
-        }
-    }
+    removeButton->doPublicMausEreignis(me);
     if (canConnect()) join->doPublicMausEreignis(me);
 }
 
 bool ServerStatus::tick(double time)
 {
     join->setPosition(gr.x - 60, gr.y - 25);
-    closeAF->setPosition(gr.x - 20, 0);
+    removeButton->setPosition(gr.x - 20, 0);
     return ZeichnungHintergrund::tick(time) || join->tick(time)
-        || closeAF->tick(time);
+        || removeButton->tick(time);
 }
 
 void ServerStatus::render(Framework::Bild& rObj)
@@ -243,9 +234,7 @@ void ServerStatus::render(Framework::Bild& rObj)
         if (statusId == 403 || statusId == 201 || statusId == 203)
             tr.renderText(5, 45, status, rObj, 0xFFFFA500);
         if (statusId == 200) tr.renderText(5, 45, status, rObj, 0xFF00FF00);
-        closeAF->render(rObj);
-        rObj.drawLinie(Punkt(gr.x - 20, 0), Punkt(gr.x, 20), 0xFFFF0000);
-        rObj.drawLinie(Punkt(gr.x - 20, 20), Punkt(gr.x, 0), 0xFFFF0000);
+        removeButton->render(rObj);
         if (canConnect()) join->render(rObj);
         rObj.releaseDrawOptions();
     }
@@ -279,7 +268,7 @@ ServerStatus::zSecrets() const
 
 bool ServerStatus::canConnect() const
 {
-    return statusId == 200 || statusId == 201 ||statusId == 203;
+    return statusId == 200 || statusId == 201 || statusId == 203;
 }
 
 ServerSelectionMenu::ServerSelectionMenu(Bildschirm* zScreen)

+ 1 - 1
FactoryCraft/ServerSelection.h

@@ -20,7 +20,7 @@ private:
     int statusId;
     int requestId;
     Framework::HashMap<Framework::Text, Framework::Text>* secrets;
-    Framework::AlphaFeld* closeAF;
+    Framework::Knopf* removeButton;
     Framework::Knopf* join;
 
 public: