Skip to content

Commit 8321fc7

Browse files
committed
new interface code always defined. Also fix locations of some Labels
1 parent 5756794 commit 8321fc7

10 files changed

Lines changed: 31 additions & 49 deletions

File tree

src/graphics/VideoBuffer.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#ifdef NEWINTERFACE
21
#include "VideoBuffer.h"
32
#define INCLUDE_FONTDATA
43
#include "font.h"
@@ -288,5 +287,3 @@ void VideoBuffer::DrawImage(pixel *img, int x, int y, int w, int h)
288287
img++;
289288
}
290289
}
291-
292-
#endif

src/gui/profile/ProfileViewer.cpp

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#ifdef NEWINTERFACE
21
#include <sstream>
32
#include "ProfileViewer.h"
43
#include "interface/Engine.h"
@@ -46,13 +45,6 @@ void ProfileViewer::MainLoop()
4645
delete asdf;
4746
}
4847

49-
std::string NumberToString(int number)
50-
{
51-
std::stringstream converter;
52-
converter << number;
53-
return converter.str();
54-
}
55-
5648
void ProfileViewer::OnTick(float dt)
5749
{
5850
if (profileInfoDownload && profileInfoDownload->CheckDone())
@@ -72,18 +64,18 @@ void ProfileViewer::OnTick(float dt)
7264
ageLabel = new Label(Point(30, 19), Point(Label::AUTOSIZE, Label::AUTOSIZE), root["User"]["Age"].asString());
7365
else
7466
ageLabel = new Label(Point(30, 19), Point(Label::AUTOSIZE, Label::AUTOSIZE), "\bgNot Provided");
75-
if (root["User"]["Website"].isString())
76-
websiteLabel = new Label(Point(50, 31), Point(Label::AUTOSIZE, Label::AUTOSIZE), root["User"]["Website"].asString());
77-
else
78-
websiteLabel = new Label(Point(50, 31), Point(Label::AUTOSIZE, Label::AUTOSIZE), "\bgNot Provided");
7967
if (root["User"]["Location"].isString())
80-
locationLabel = new Label(Point(54, 43), Point(Label::AUTOSIZE, Label::AUTOSIZE), root["User"]["Location"].asString());
68+
locationLabel = new Label(Point(54, 31), Point(Label::AUTOSIZE, Label::AUTOSIZE), root["User"]["Location"].asString());
69+
else
70+
locationLabel = new Label(Point(54, 31), Point(Label::AUTOSIZE, Label::AUTOSIZE), "\bgNot Provided");
71+
if (root["User"]["Website"].isString())
72+
websiteLabel = new Label(Point(50, 43), Point(Label::AUTOSIZE, Label::AUTOSIZE), root["User"]["Website"].asString());
8173
else
82-
locationLabel = new Label(Point(54, 43), Point(Label::AUTOSIZE, Label::AUTOSIZE), "\bgNot Provided");
74+
websiteLabel = new Label(Point(50, 43), Point(Label::AUTOSIZE, Label::AUTOSIZE), "\bgNot Provided");
8375
if (root["User"]["Biography"].isString())
84-
biographyLabel = new Label(Point(8, 103), Point(240, Label::AUTOSIZE), root["User"]["Biography"].asCString(), true);
76+
biographyLabel = new Label(Point(8, 115), Point(240, Label::AUTOSIZE), root["User"]["Biography"].asCString(), true);
8577
else
86-
biographyLabel = new Label(Point(8, 103), Point(240, Label::AUTOSIZE), "\bgNot Provided", true);
78+
biographyLabel = new Label(Point(8, 115), Point(240, Label::AUTOSIZE), "\bgNot Provided", true);
8779

8880
this->AddComponent(ageLabel);
8981
this->AddComponent(locationLabel);
@@ -105,7 +97,7 @@ void ProfileViewer::OnTick(float dt)
10597
}
10698
catch (std::exception &e)
10799
{
108-
biographyLabel = new Label(Point(8, 79), Point(230, Label::AUTOSIZE), "\brError parsing data from server", true);
100+
biographyLabel = new Label(Point(8, 115), Point(230, Label::AUTOSIZE), "\brError parsing data from server", true);
109101
this->AddComponent(biographyLabel);
110102
}
111103

@@ -138,13 +130,11 @@ void ProfileViewer::OnDraw(VideoBuffer *buf)
138130
if (avatar)
139131
buf->DrawImage(avatar, 210, 10, 40, 40);
140132
buf->DrawText(10, 22, "Age:", 175, 175, 175, 255);
141-
buf->DrawText(10, 34, "Website:", 175, 175, 175, 255);
142-
buf->DrawText(10, 46, "Location:", 175, 175, 175, 255);
133+
buf->DrawText(10, 34, "Location:", 175, 175, 175, 255);
134+
buf->DrawText(10, 46, "Website:", 175, 175, 175, 255);
143135
buf->DrawText(10, 58, "Saves:", 175, 175, 175, 255);
144136
buf->DrawText(15, 70, "Count:", 175, 175, 175, 255);
145137
buf->DrawText(15, 82, "Average Score:", 175, 175, 175, 255);
146138
buf->DrawText(15, 94, "Highest Score:", 175, 175, 175, 255);
147139
buf->DrawText(10, 106, "Biography:", 175, 175, 175, 255);
148140
}
149-
150-
#endif

src/gui/profile/ProfileViewer.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#ifdef NEWINTERFACE
21
#ifndef PROFILEVIEWER_H
32
#define PROFILEVIEWER_H
43

@@ -27,4 +26,3 @@ class ProfileViewer : public Window_
2726
};
2827

2928
#endif
30-
#endif

src/interface.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@
6666
#include "simulation/ToolNumbers.h"
6767
#include "simulation/GolNumbers.h"
6868

69+
#include "gui/profile/ProfileViewer.h"
70+
6971
SDLMod sdl_mod;
7072
int sdl_key, sdl_rkey, sdl_wheel, sdl_ascii, sdl_zoom_trig=0;
7173
#if defined(LIN) && defined(SDL_VIDEO_DRIVER_X11)
@@ -1298,7 +1300,10 @@ void draw_svf_ui(pixel *vid_buf, int alternate)// all the buttons at the bottom
12981300
//the login button
12991301
drawtext(vid_buf, XRES-122+BARSIZE/*388*/, YRES+(MENUSIZE-13), "\x84", 255, 255, 255, 255);
13001302
if (svf_login)
1303+
{
13011304
drawtextmax(vid_buf, XRES-104+BARSIZE/*406*/, YRES+(MENUSIZE-12), 66, svf_user, 255, 255, 255, 255);
1305+
drawdots(vid_buf, XRES+BARSIZE-108, YRES+(MENUSIZE-15), 12, c, c, c, 255);
1306+
}
13021307
else
13031308
drawtext(vid_buf, XRES-104+BARSIZE/*406*/, YRES+(MENUSIZE-12), "[sign in]", 255, 255, 255, 255);
13041309
drawrect(vid_buf, XRES-125+BARSIZE/*385*/, YRES+(MENUSIZE-16), 91, 14, 255, 255, 255, 255);
@@ -5096,6 +5101,8 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date, int instant_open)
50965101
ui_edit ed;
50975102
ui_copytext ctb;
50985103

5104+
const char *profileToOpen = "";
5105+
50995106
pixel *old_vid=(pixel *)calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE);
51005107
if (!old_vid || !info)
51015108
return 0;
@@ -5464,10 +5471,11 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date, int instant_open)
54645471
if (b && !bq && mx > 61+(XRES/2) && mx < 61+(XRES/2)+textwidth(info->commentauthors[cc]) && my > ccy+58+comment_scroll && my < ccy+70+comment_scroll && my < YRES+MENUSIZE-76-ed.h+2)
54655472
if (sdl_mod & (KMOD_CTRL|KMOD_META)) //open profile
54665473
{
5467-
char link[128];
5474+
/*char link[128];
54685475
strcpy(link, "http://" SERVER "/User.html?Name=");
54695476
strcaturl(link, info->commentauthorsunformatted[cc]);
5470-
open_link(link);
5477+
open_link(link);*/
5478+
profileToOpen = info->commentauthorsunformatted[cc];
54715479
}
54725480
else if (sdl_mod & KMOD_SHIFT) //, or search for a user's saves
54735481
{
@@ -5854,6 +5862,13 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date, int instant_open)
58545862

58555863
if (lasttime<TIMEOUT)
58565864
lasttime++;
5865+
5866+
if (strcmp(profileToOpen, ""))
5867+
{
5868+
ProfileViewer *temp = new ProfileViewer(profileToOpen);
5869+
delete temp;
5870+
profileToOpen = "";
5871+
}
58575872
}
58585873
//Prevent those mouse clicks being passed down.
58595874
while (!sdl_poll())

src/interface/Button.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#ifdef NEWINTERFACE
1+
#ifdef TODOFIXTHIS
22
#include "Button.h"
33
#include "graphics.h"
44
#include "graphics/VideoBuffer.h"

src/interface/Engine.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#ifdef NEWINTERFACE
21
#include <SDL/SDL.h>
32
#include "Engine.h"
43
#include "interface.h"
@@ -200,5 +199,3 @@ void Engine::CloseWindow(Window_ *window)
200199
top = NULL;
201200
}
202201
}
203-
204-
#endif

src/interface/Label.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#ifdef NEWINTERFACE
21
#include <algorithm>
32
#include "Label.h"
43
#include "graphics.h"
@@ -327,5 +326,3 @@ void Label::OnTick()
327326
if (!IsClicked() && numClicks && lastClick+300 < SDL_GetTicks())
328327
numClicks = 0;
329328
}
330-
331-
#endif

src/interface/Textbox.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#ifdef NEWINTERFACE
21
#include <algorithm>
32
#include "Textbox.h"
43
#include "graphics/VideoBuffer.h"
@@ -158,4 +157,3 @@ void Textbox::OnDraw(VideoBuffer* vid)
158157
else
159158
vid->DrawRect(position.X-1, position.Y-1, size.X+2, size.Y+2, 150, 150, 150, 255);
160159
}
161-
#endif

src/interface/Window.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#ifdef NEWINTERFACE
21
#include "Window.h"
32
#include "Engine.h"
43
#include "Label.h"
@@ -170,5 +169,3 @@ void Window_::DoKeyRelease(int key, unsigned short character, unsigned char modi
170169

171170
OnKeyRelease(key, character, modifiers);
172171
}
173-
174-
#endif

src/main.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,9 @@
8282
#include "simulation/ToolNumbers.h"
8383
#include "simulation/elements/LIFE.h"
8484

85-
#ifdef NEWINTERFACE
85+
// new interface stuff
8686
#include "interface/Engine.h"
8787
#include "gui/profile/ProfileViewer.h"
88-
#endif
8988

9089
pixel *vid_buf;
9190

@@ -1892,10 +1891,6 @@ int main(int argc, char *argv[])
18921891
}
18931892
if (sdl_key=='1')
18941893
{
1895-
#ifdef NEWINTERFACE
1896-
Engine* asdf = new Engine();
1897-
asdf->MainLoop();
1898-
#endif
18991894
if (sdl_mod & (KMOD_CTRL|KMOD_META))
19001895
display_mode = display_mode&DISPLAY_AIRV ? display_mode&!DISPLAY_AIRV:display_mode|DISPLAY_AIRV;
19011896
else
@@ -2879,14 +2874,12 @@ int main(int argc, char *argv[])
28792874
}
28802875
else if (x>=(XRES+BARSIZE-(510-385)) && x<=(XRES+BARSIZE-(510-476)))
28812876
{
2882-
#ifdef NEWINTERFACE
2883-
if (x <= XRES+BARSIZE-(510-399))
2877+
if (svf_login && x <= XRES+BARSIZE-108)
28842878
{
28852879
ProfileViewer *temp = new ProfileViewer(svf_user);
28862880
delete temp;
28872881
}
28882882
else
2889-
#endif
28902883
{
28912884
login_ui(vid_buf);
28922885
if (svf_login)

0 commit comments

Comments
 (0)