From 7c80bbfebb441bb7c9fd587b916cc006ae98ab37 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 16 Apr 2006 16:32:14 +0000 Subject: [PATCH] =?UTF-8?q?lua-skripting=20f=C3=BCr=20gmtool=20fertig?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/eressea/Jamfile | 1 + src/eressea/gmmain.cpp | 2 +- src/eressea/gmtool.c | 37 ++++++++++++++++++++++++------------ src/eressea/gmtool_structs.h | 2 +- 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/eressea/Jamfile b/src/eressea/Jamfile index fb8713f11..842b5320a 100644 --- a/src/eressea/Jamfile +++ b/src/eressea/Jamfile @@ -48,6 +48,7 @@ LUASERVER_SOURCES = GMTOOL_SOURCES = $(SHARED_BINDINGS) + gm.cpp listbox.c console.c editing.c diff --git a/src/eressea/gmmain.cpp b/src/eressea/gmmain.cpp index 3dbc1e8a9..1e25b7804 100644 --- a/src/eressea/gmmain.cpp +++ b/src/eressea/gmmain.cpp @@ -45,7 +45,7 @@ lua_init(void) bind_unit(L); bind_ship(L); bind_building(L); - + bind_gmtool(L); lua_readline = curses_readline; return L; } diff --git a/src/eressea/gmtool.c b/src/eressea/gmtool.c index 9ffa9bb86..f25330336 100644 --- a/src/eressea/gmtool.c +++ b/src/eressea/gmtool.c @@ -275,7 +275,7 @@ init_curses(void) map_region * mr_get(const view * vi, int xofs, int yofs) { - return vi->regions + xofs + yofs * vi->extent.width; + return vi->regions + xofs + yofs * vi->size.width; } static coordinate * @@ -987,9 +987,22 @@ handlekey(state * st, int c) break; case 'L': if (global.vm_state) { + move(0, 0); + refresh(); lua_do((lua_State*)global.vm_state); + /* todo: do this from inside the script */ + clear(); + st->wnd_info->update |= 1; + st->wnd_status->update |= 1; + st->wnd_map->update |= 1; } break; + case 12: /* Ctrl-L */ + clear(); + st->wnd_info->update |= 1; + st->wnd_status->update |= 1; + st->wnd_map->update |= 1; + break; case 'H': select_regions(st, MODE_HIGHLIGHT); break; @@ -1125,17 +1138,17 @@ init_view(view * display, WINDOW * win) display->topleft.y = 1; display->topleft.p = 0; display->plane = 0; - display->extent.width = getmaxx(win)/TWIDTH; - display->extent.height = getmaxy(win)/THEIGHT; - display->regions = calloc(display->extent.height * display->extent.width, sizeof(map_region)); + display->size.width = getmaxx(win)/TWIDTH; + display->size.height = getmaxy(win)/THEIGHT; + display->regions = calloc(display->size.height * display->size.width, sizeof(map_region)); } static void update_view(view * vi) { int i, j; - for (i=0;i!=vi->extent.width;++i) { - for (j=0;j!=vi->extent.height;++j) { + for (i=0;i!=vi->size.width;++i) { + for (j=0;j!=vi->size.height;++j) { map_region * mr = mr_get(vi, i, j); mr->coord.x = vi->topleft.x + i - j/2; mr->coord.y = vi->topleft.y + j; @@ -1206,19 +1219,19 @@ run_mapper(void) st.wnd_map->update |= 1; } if (p.y < tl.y) { - vi->topleft.y = st.cursor.y-vi->extent.height/2; + vi->topleft.y = st.cursor.y-vi->size.height/2; st.wnd_map->update |= 1; } - else if (p.y >= tl.y + vi->extent.height * THEIGHT) { - vi->topleft.y = st.cursor.y-vi->extent.height/2; + else if (p.y >= tl.y + vi->size.height * THEIGHT) { + vi->topleft.y = st.cursor.y-vi->size.height/2; st.wnd_map->update |= 1; } if (p.x <= tl.x) { - vi->topleft.x = st.cursor.x+(st.cursor.y-vi->topleft.y)/2-vi->extent.width / 2; + vi->topleft.x = st.cursor.x+(st.cursor.y-vi->topleft.y)/2-vi->size.width / 2; st.wnd_map->update |= 1; } - else if (p.x >= tl.x + vi->extent.width * TWIDTH-1) { - vi->topleft.x = st.cursor.x+(st.cursor.y-vi->topleft.y)/2-vi->extent.width / 2; + else if (p.x >= tl.x + vi->size.width * TWIDTH-1) { + vi->topleft.x = st.cursor.x+(st.cursor.y-vi->topleft.y)/2-vi->size.width / 2; st.wnd_map->update |= 1; } diff --git a/src/eressea/gmtool_structs.h b/src/eressea/gmtool_structs.h index 0f3b90c92..7d4e9859a 100644 --- a/src/eressea/gmtool_structs.h +++ b/src/eressea/gmtool_structs.h @@ -42,7 +42,7 @@ typedef struct view { struct map_region * regions; int plane; coordinate topleft; /* upper left corner in map. */ - extent extent; /* dimensions. */ + extent size; /* dimensions. */ } view; typedef struct tag {