]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add description pane
authorTimePath <andrew.hardaker1995@gmail.com>
Sun, 16 Aug 2015 12:12:23 +0000 (22:12 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Sun, 16 Aug 2015 12:12:23 +0000 (22:12 +1000)
qcsrc/menu/xonotic/dialog_media_guide.qc
qcsrc/menu/xonotic/dialog_media_guide_description.qc [new file with mode: 0644]
qcsrc/menu/xonotic/dialog_media_guide_entries.qc
qcsrc/menu/xonotic/dialog_media_guide_topics.qc

index af818ad2deb09070502d599e8b82e176b59dbb9f..fce5c04a4d5a6df837e6e49c3d2b7ea44a36bee2 100644 (file)
@@ -93,17 +93,19 @@ ENDCLASS(MapSource)
 
 #include "dialog_media_guide_topics.qc"
 #include "dialog_media_guide_entries.qc"
+#include "dialog_media_guide_description.qc"
 #include "tab.qc"
 CLASS(XonoticGuideTab, XonoticTab)
     ATTRIB(XonoticGuideTab, rows, float, 21)
     ATTRIB(XonoticGuideTab, columns, float, 6)
        ATTRIB(XonoticGuideTab, intendedWidth, float, 1)
     METHOD(XonoticGuideTab, fill, void(entity))
-    METHOD(XonoticGuideTab, topicChangeNotify, void(entity))
-    METHOD(XonoticGuideTab, topicSelectNotify, void(entity))
+    METHOD(XonoticGuideTab, topicChangeNotify, void(entity, entity))
+    METHOD(XonoticGuideTab, entryChangeNotify, void(entity, entity))
 
-    ATTRIB(XonoticGuideTab, topicList, entity, NEW(XonoticTopicList, NEW(TopicSource), this))
+    ATTRIB(XonoticGuideTab, topicList, entity, NEW(XonoticTopicList, NEW(TopicSource)))
     ATTRIB(XonoticGuideTab, entryList, entity, NEW(XonoticEntryList, NULL))
+    ATTRIB(XonoticGuideTab, descriptionPane, entity, NEW(XonoticGuideDescription))
 
     INIT(XonoticGuideTab) {
         this.configureDialog(this);
@@ -116,32 +118,44 @@ ENDCLASS(XonoticGuideTab)
 void XonoticGuideTab_fill(entity this)
 {
     entity topics = this.topicList;
+        topics.onChange = XonoticGuideTab_topicChangeNotify;
+        topics.onChangeEntity = this;
     entity entries = this.entryList;
+        entries.onChange = XonoticGuideTab_entryChangeNotify;
+        entries.onChangeEntity = this;
     entity filter = entries.stringFilterBox = makeXonoticInputBox(false, string_null);
         filter.keyDown = MapList_StringFilterBox_keyDown;
         filter.onChange = MapList_StringFilterBox_Change;
         filter.onChangeEntity = entries;
     entries.controlledTextbox = filter;
+    entity description = this.descriptionPane;
 
-    this.gotoRC(this, 0, 0);
-        this.TD(this, 1, 3 / 2, makeXonoticHeaderLabel(_("Topic")));
+    int
+    col = 0, width = 1.5;
+    this.gotoRC(this, 0, col);
+        this.TD(this, 1, width, makeXonoticHeaderLabel(_("Topic")));
     this.TR(this);
-        this.TD(this, this.rows - 1, 3 / 2, topics);
+        this.TD(this, this.rows - 1, width, topics);
 
-    this.gotoRC(this, 0, 3 / 2);
-        this.setFirstColumn(this, this.currentColumn);
-        this.TD(this, 1, 2, makeXonoticHeaderLabel(_("Entry")));
+    col += width, width = 2;
+    this.gotoRC(this, 0, col); this.setFirstColumn(this, this.currentColumn);
+        this.TD(this, 1, width, makeXonoticHeaderLabel(_("Entry")));
     this.TR(this);
-        this.TD(this, this.rows - 1 - 1, 2, entries);
-
-    this.gotoRC(this, this.rows - 1, this.firstColumn);
+        this.TD(this, this.rows - 1 - 1, width, entries);
+    this.gotoRC(this, this.rows - 1, col);
         this.TD(this, 1, 0.3, makeXonoticTextLabel(0, _("Filter:")));
-        this.TD(this, 1, 2 - 0.3, filter);
+        this.TD(this, 1, width - 0.3, filter);
+
+    col += width, width = 2.5;
+    this.gotoRC(this, 0, col); this.setFirstColumn(this, this.currentColumn);
+        this.TD(this, 1, width, makeXonoticHeaderLabel(_("Description")));
+    this.TR(this);
+        this.TD(this, this.rows - 1, width, description);
 
-    this.topicChangeNotify(this);
+    this.topicChangeNotify(topics, this);
 }
 
-void XonoticGuideTab_topicChangeNotify(entity this)
+void XonoticGuideTab_topicChangeNotify(entity, entity this)
 {
     entity topics = this.topicList;
     entity entries = this.entryList;
@@ -155,7 +169,11 @@ void XonoticGuideTab_topicChangeNotify(entity this)
     entries.refilter(entries);
 }
 
-void XonoticGuideTab_topicSelectNotify(entity this) { this.setFocus(this, this.entryList); }
+void XonoticGuideTab_entryChangeNotify(entity, entity this)
+{
+    entity desc = this.descriptionPane;
+    desc.setDescription(desc, sprintf("item %.0f\n", this.entryList.selectedItem));
+}
 
 entity MapSource_getEntry(int i)
 {
diff --git a/qcsrc/menu/xonotic/dialog_media_guide_description.qc b/qcsrc/menu/xonotic/dialog_media_guide_description.qc
new file mode 100644 (file)
index 0000000..9f8bbb8
--- /dev/null
@@ -0,0 +1,23 @@
+#ifndef DIALOG_MEDIA_GUIDE_DESCRIPTION_H
+#define DIALOG_MEDIA_GUIDE_DESCRIPTION_H
+#include "credits.qc"
+CLASS(XonoticGuideDescription, XonoticCreditsList)
+    ATTRIB(XonoticGuideDescription, description, string, string_null)
+    METHOD(XonoticGuideDescription, setDescription, void(entity, string))
+    void XonoticGuideDescription_setDescription(entity this, string desc)
+    {
+        string current = this.description;
+        if (current) strunzone(current);
+        this.description = strzone(desc);
+        int n = tokenizebyseparator(desc, "\n");
+        this.nItems = n;
+    }
+
+    METHOD(XonoticGuideDescription, drawListBoxItem, void(entity, int, vector, bool, bool))
+    void XonoticGuideDescription_drawListBoxItem(entity this, int i, vector absSize, bool isSelected, bool isFocused)
+    {
+        tokenizebyseparator(this.description, "\n");
+        draw_Text(this.realUpperMargin * eY, argv(i), this.realFontSize, '1 1 1', 1, 0);
+    }
+ENDCLASS(XonoticGuideDescription)
+#endif
index eede28ba3f5e4b133917faeaa903efeeea298dff..0cc651ce672d9dbb4d3dfced5ffb3800e7d67510 100644 (file)
@@ -23,6 +23,7 @@ CLASS(XonoticEntryList, XonoticListBox)
     METHOD(XonoticEntryList, keyDown, float(entity, float, float, float))
     METHOD(XonoticEntryList, refilter, void(entity))
     METHOD(XonoticEntryList, resizeNotify, void(entity, vector, vector, vector, vector))
+    METHOD(XonoticEntryList, setSelected, void(entity, int))
 
     ATTRIB(XonoticEntryList, source, DataSource, NULL)
 
@@ -118,4 +119,10 @@ void XonoticEntryList_resizeNotify(entity this, vector relOrigin, vector relSize
     this.columnNameOrigin = this.columnPreviewOrigin + this.columnPreviewSize + this.realFontSize.x;
     this.columnNameSize = 1 - this.columnPreviewSize - 2 * this.realFontSize.x;
 }
+
+void XonoticEntryList_setSelected(entity this, int i)
+{
+    super.setSelected(this, i);
+    this.onChange(this, this.onChangeEntity);
+}
 #endif
index b3845c67bf5ce37f753f50233af968d6fd620d0c..aa68a9451e970f8af4efc8898df865e4f0e5665c 100644 (file)
@@ -18,12 +18,10 @@ CLASS(XonoticTopicList, XonoticListBox)
     METHOD(XonoticTopicList, setSelected, void(entity, int))
 
     ATTRIB(XonoticTopicList, source, DataSource, NULL)
-    ATTRIB(XonoticTopicList, listener, entity, NULL)
 
-    CONSTRUCTOR(XonoticTopicList, DataSource _source, entity _listener) {
+    CONSTRUCTOR(XonoticTopicList, DataSource _source) {
        CONSTRUCT(XonoticTopicList);
        this.source = _source;
-       this.listener = _listener;
        this.nItems = _source.reload("");
        this.configureXonoticListBox(this);
     }
@@ -62,13 +60,6 @@ bool XonoticTopicList_keyDown(entity this, float scan, float ascii, float shift)
 {
     if (scan == K_ENTER || scan == K_KP_ENTER) {
         m_play_click_sound(MENU_SOUND_EXECUTE);
-        entity l = this.listener;
-        if (l) {
-               void(entity) func = l.topicSelectNotify;
-               if (func) {
-                       func(l);
-               }
-        }
         return true;
     }
     return super.keyDown(this, scan, ascii, shift);
@@ -91,12 +82,6 @@ void XonoticTopicList_resizeNotify(entity this, vector relOrigin, vector relSize
 void XonoticTopicList_setSelected(entity this, int i)
 {
     super.setSelected(this, i);
-    entity l = this.listener;
-       if (l) {
-               void(entity) func = l.topicChangeNotify;
-               if (func) {
-                       func(l);
-               }
-       }
+    this.onChange(this, this.onChangeEntity);
 }
 #endif