#include "xonotic/dialog_multiplayer_playersetup_waypoint.c"
#include "xonotic/dialog_multiplayer_demo.c"
#include "xonotic/demolist.c"
+#include "xonotic/screenshotimage.c"
#include "xonotic/dialog_multiplayer_screenshot.c"
#include "xonotic/dialog_multiplayer_screenshot_screenshotviewer.c"
#include "xonotic/screenshotlist.c"
{
if (me.currentScrPath)
strunzone(me.currentScrPath);
- if (scrImage == "")
- scrImage = "/gfx/transparent";
me.currentScrPath = strzone(scrImage);
- me.screenshotImage.configureImage(me.screenshotImage, me.currentScrPath);
- me.screenshotImage.updateAspect(me.screenshotImage);
+ me.screenshotImage.configureXonoticScreenshotImage(me.screenshotImage, me.currentScrPath);
}
void XonoticScreenshotBrowserTab_fill(entity me)
{
e.onClick = StartScreenshot_Click;
e.onClickEntity = slist;
me.TR(me);
- me.TD(me, me.rows - 10, me.columns, e = makeXonoticImage(string_null, -1));
- e.src = "/gfx/transparent"; // in case there isn't any screenshot to show
+ me.TD(me, me.rows - 10, me.columns, e = makeXonoticScreenshotImage());
+ e.showTitle = 0;
me.screenshotImage = e;
slist.screenshotPreview = e;
slist.screenshotBrowserDialog = me;
#ifdef INTERFACE
-CLASS(XonoticScreenshotViewerDialog) EXTENDS(XonoticRootDialog)
+CLASS(XonoticScreenshotViewerDialog) EXTENDS(XonoticDialog)
METHOD(XonoticScreenshotViewerDialog, fill, void(entity))
METHOD(XonoticScreenshotViewerDialog, keyDown, float(entity, float, float, float))
METHOD(XonoticScreenshotViewerDialog, loadScreenshot, void(entity, string))
ATTRIB(XonoticScreenshotViewerDialog, title, string, "Screenshot Viewer")
+ ATTRIB(XonoticScreenshotViewerDialog, name, string, "ScreenshotViewer")
ATTRIB(XonoticScreenshotViewerDialog, intendedWidth, float, 1)
ATTRIB(XonoticScreenshotViewerDialog, rows, float, 25)
ATTRIB(XonoticScreenshotViewerDialog, columns, float, 6.5)
- ATTRIB(XonoticScreenshotViewerDialog, screenshotImage, entity, NULL)
ATTRIB(XonoticScreenshotViewerDialog, color, vector, SKINCOLOR_DIALOG_MULTIPLAYER)
ATTRIB(XonoticScreenshotViewerDialog, scrList, entity, NULL)
- ATTRIB(XonoticScreenshotViewerDialog, titleLabel, entity, NULL)
-
- ATTRIB(XonoticScreenshotViewerDialog, currentScrName, string, string_null)
+ ATTRIB(XonoticScreenshotViewerDialog, screenshotImage, entity, NULL)
ATTRIB(XonoticScreenshotViewerDialog, currentScrPath, string, string_null)
ENDCLASS(XonoticScreenshotViewerDialog)
#endif
if (me.currentScrPath)
strunzone(me.currentScrPath);
me.currentScrPath = strzone(scrImage);
- me.screenshotImage.configureImage(me.screenshotImage, me.currentScrPath);
- me.screenshotImage.updateAspect(me.screenshotImage);
-
- if (me.currentScrName)
- strunzone(me.currentScrName);
- me.currentScrName = strzone(substring(scrImage, 13, strlen(scrImage) - 13));
- me.titleLabel.setText(me.titleLabel, me.currentScrName);
+ me.screenshotImage.configureXonoticScreenshotImage(me.screenshotImage, me.currentScrPath);
}
void prevScreenshot_Click(entity btn, entity me)
{
{
me.scrList.goScreenshot(me.scrList, +1);
}
-
float XonoticScreenshotViewerDialog_keyDown(entity me, float key, float ascii, float shift)
{
switch(key)
void XonoticScreenshotViewerDialog_fill(entity me)
{
entity e;
-
me.TR(me);
- me.TD(me, me.rows - 1, me.columns, e = makeXonoticImage(string_null, -1));
+ me.TD(me, me.rows - 1, me.columns, e = makeXonoticScreenshotImage());
me.screenshotImage = e;
- me.TD(me, 1, me.columns, e = makeXonoticTextLabel(0.5, ""));
- me.titleLabel = e;
me.gotoRC(me, me.rows - 1, 0);
me.TD(me, 1, me.columns/2, e = makeXonoticButton("Previous", '0 0 0'));
e.onClick = prevScreenshot_Click;
--- /dev/null
+#ifdef INTERFACE
+CLASS(XonoticScreenshotImage) EXTENDS(Image)
+ METHOD(XonoticScreenshotImage, configureXonoticScreenshotImage, void(entity, string))
+ METHOD(XonoticScreenshotImage, draw, void(entity))
+ METHOD(XonoticScreenshotImage, resizeNotify, void(entity, vector, vector, vector, vector))
+ ATTRIB(XonoticScreenshotImage, realFontSize, vector, '0 0 0')
+ ATTRIB(XonoticScreenshotImage, fontSize, float, SKINFONTSIZE_NORMAL)
+ ATTRIB(XonoticScreenshotImage, showTitle, float, 1)
+ ATTRIB(XonoticScreenshotImage, showTitleTime, float, 0)
+ ATTRIB(XonoticScreenshotImage, screenshotTitle, string, string_null)
+ENDCLASS(XonoticScreenshotImage)
+entity makeXonoticScreenshotImage();
+#endif
+
+#ifdef IMPLEMENTATION
+entity makeXonoticScreenshotImage()
+{
+ entity me;
+ me = spawnXonoticScreenshotImage();
+ me.configureXonoticScreenshotImage(me, string_null);
+ return me;
+}
+
+void XonoticScreenshotImage_configureXonoticScreenshotImage(entity me, string theImage)
+{
+ me.configureImage(me, theImage);
+ me.forcedAspect = -1;
+ me.showTitleTime = time + 3; // show title for 3 seconds
+ me.updateAspect(me);
+ if (me.screenshotTitle)
+ strunzone(me.screenshotTitle);
+ me.screenshotTitle = strzone(substring(me.src, 13, strlen(theImage) - 13)); //strip "/screenshots/"
+}
+
+void XonoticScreenshotImage_draw(entity me)
+{
+ if (me.src != "")
+ {
+ SUPER(XonoticScreenshotImage).draw(me);
+ if (me.showTitle && time < me.showTitleTime + 1) // fade title out in 1 second
+ {
+ float alpha = (1 - (time - me.showTitleTime));
+ draw_CenterText('0.5 0 0', me.screenshotTitle, me.realFontSize, '1 1 1', alpha, FALSE);
+ }
+ }
+}
+
+void XonoticScreenshotImage_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
+{
+ SUPER(XonoticScreenshotImage).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
+ me.realFontSize_y = me.fontSize / absSize_y;
+ me.realFontSize_x = me.fontSize / absSize_x;
+}
+#endif