Debian Codegraph @

src/state/demo-script.cpp

raw
1 /*
2 * Copyright (C) 2004 Ivo Danihelka ([email protected])
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 */
9 #include "demo-script.h"
10
11 #include "Path.h"
12 #include "DemoMode.h"
13 #include "Picture.h"
14
15 #include "def-script.h"
16
17 //-----------------------------------------------------------------
18 inline DemoMode *
19 getDemo(lua_State *L)
20 {
21 return dynamic_cast<DemoMode*>(script_getLeader(L));
22 }
23
24 //-----------------------------------------------------------------
25 /**
26 * void demo_display(picture, x, y)
27 */
28 int
29 script_demo_display(lua_State *L) throw()
30 {
31 BEGIN_NOEXCEPTION;
32 const char *filename = luaL_checkstring(L, 1);
33 int x = luaL_checkint(L, 2);
34 int y = luaL_checkint(L, 3);
35
36 Picture *picture = new Picture(Path::dataReadPath(filename), V2(x, y));
37 getDemo(L)->action_display(picture);
38 END_NOEXCEPTION;
39 return 0;
40 }
41