| 1 |
sf-pippijn |
1.1 |
#include "dclient/widgets.h" |
| 2 |
|
|
#include "dclient/widgets/inventory.h" |
| 3 |
|
|
#include "dclient/widgets/map.h" |
| 4 |
|
|
#include "dclient/widgets/query.h" |
| 5 |
|
|
#include "dclient/widgets/stats.h" |
| 6 |
|
|
|
| 7 |
|
|
#include <ndk++/application.hh> |
| 8 |
|
|
#include <ndk++/frame.hh> |
| 9 |
|
|
|
| 10 |
sf-pippijn |
1.4 |
#include <ncurses/assert.hh> |
| 11 |
|
|
|
| 12 |
|
|
#include <csignal> |
| 13 |
|
|
|
| 14 |
sf-pippijn |
1.1 |
// distance between boxes |
| 15 |
|
|
static int const DX = 4; |
| 16 |
|
|
static int const DY = 2; |
| 17 |
|
|
|
| 18 |
|
|
// stats height |
| 19 |
|
|
static int const SH = 10; |
| 20 |
|
|
|
| 21 |
|
|
using ndk::app; |
| 22 |
|
|
|
| 23 |
|
|
void |
| 24 |
|
|
widgets::repack () |
| 25 |
|
|
{ |
| 26 |
|
|
map->move (DX, DY, ndk::absolute); |
| 27 |
|
|
map->resize (app ().width () / 2 - DX * 2, app ().height () / 3 * 2); |
| 28 |
|
|
|
| 29 |
|
|
info.move (map->right_x () + DX, DY, ndk::absolute); |
| 30 |
|
|
info.resize (app ().width () - map->width () - DX * 3, map->height () - SH - DY); |
| 31 |
|
|
|
| 32 |
|
|
stats->move (info.x (), info.bottom_y () + DY, ndk::absolute); |
| 33 |
|
|
stats->resize (info.width (), SH); |
| 34 |
|
|
|
| 35 |
|
|
input.move (map->x (), map->bottom_y () + 1, ndk::absolute); |
| 36 |
|
|
input.resize (map->width () + DY + info.width () + DY); |
| 37 |
|
|
|
| 38 |
|
|
inventory->move (map->x (), input.bottom_y () + 1, ndk::absolute); |
| 39 |
sf-pippijn |
1.4 |
inventory->resize (map->width (), app ().height () - map->height () - DY * 3); |
| 40 |
sf-pippijn |
1.1 |
|
| 41 |
|
|
container->move (stats->x (), inventory->y (), ndk::absolute); |
| 42 |
sf-pippijn |
1.4 |
container->resize (stats->width (), inventory->height ()); |
| 43 |
sf-pippijn |
1.1 |
|
| 44 |
|
|
query->move ( (app ().width () - query->width ()) / 2 |
| 45 |
|
|
, (app ().height () - query->height ()) / 2 |
| 46 |
|
|
, ndk::absolute |
| 47 |
|
|
); |
| 48 |
|
|
|
| 49 |
|
|
query_input.resize (query->width () - 2); |
| 50 |
|
|
query_input.move (query->x () + 1, query->bottom_y () - 2, ndk::absolute); |
| 51 |
|
|
} |
| 52 |
|
|
|
| 53 |
|
|
void |
| 54 |
|
|
widgets::resize () |
| 55 |
|
|
{ |
| 56 |
|
|
repack (); |
| 57 |
sf-pippijn |
1.4 |
map->visualize (); |
| 58 |
sf-pippijn |
1.1 |
info.visualize (); |
| 59 |
sf-pippijn |
1.4 |
stats->visualize (); |
| 60 |
|
|
inventory->visualize (); |
| 61 |
|
|
container->visualize (); |
| 62 |
sf-pippijn |
1.1 |
} |
| 63 |
|
|
|
| 64 |
|
|
widgets::widgets () |
| 65 |
|
|
: map (new map_widget) |
| 66 |
|
|
, stats (new stats_widget) |
| 67 |
|
|
, inventory (new inventory_widget) |
| 68 |
|
|
, container (new inventory_widget) |
| 69 |
|
|
, query (new query_widget) |
| 70 |
|
|
, query_input ("", query.get ()) |
| 71 |
|
|
{ |
| 72 |
|
|
query->resize (10, 5); |
| 73 |
|
|
|
| 74 |
sf-pippijn |
1.4 |
resize (); |
| 75 |
sf-pippijn |
1.1 |
|
| 76 |
sf-pippijn |
1.3 |
map->focus (); |
| 77 |
|
|
//invmenu.focus (); |
| 78 |
sf-pippijn |
1.4 |
|
| 79 |
|
|
ndk::app ().resize_handler = [this] { this->resize (); }; |
| 80 |
sf-pippijn |
1.1 |
} |
| 81 |
|
|
|
| 82 |
|
|
widgets::~widgets () |
| 83 |
|
|
{ |
| 84 |
|
|
} |