diff options
| author | Alexander <alex@cogarr.net> | 2020-06-29 15:29:03 -0400 |
|---|---|---|
| committer | Alexander <alex@cogarr.net> | 2020-06-29 15:29:03 -0400 |
| commit | 80789508b9655d25629223b9dcc84b4cfb77ce45 (patch) | |
| tree | 37e140e532af61c1ca4699c8b6254cf2cb07ed02 /src/client/lua_api | |
| parent | 44a1421c393632978d59c0698a93ae22243b97e9 (diff) | |
| download | brokengine-80789508b9655d25629223b9dcc84b4cfb77ce45.tar.gz brokengine-80789508b9655d25629223b9dcc84b4cfb77ce45.tar.bz2 brokengine-80789508b9655d25629223b9dcc84b4cfb77ce45.zip | |
Updates for mdoc
Also more tests
Diffstat (limited to 'src/client/lua_api')
21 files changed, 384 insertions, 119 deletions
diff --git a/src/client/lua_api/gui/iguibutton.cpp b/src/client/lua_api/gui/iguibutton.cpp index 3d4580b..cdbea77 100644 --- a/src/client/lua_api/gui/iguibutton.cpp +++ b/src/client/lua_api/gui/iguibutton.cpp @@ -17,9 +17,6 @@ extern "C" { #include <shared/util/hashmap.hpp> #include <shared/lua_api/common.hpp> -/*** -@module gui -*/ using namespace irr; using namespace core; using namespace gui; @@ -30,16 +27,16 @@ char lhashkey[20]; /*** Creates a new button. Buttons may have the following fields set for callbacks: + .onClick(self) - .onFocus(self) - .onUnfocus(self) - .onHover(self) - .onLeave(self) -@function newbutton() + +It may additionally call any @{iguielement} callbacks + +@function gui.newbutton() @tparam rect dimensions The rectangle to place the button at. If the box has a parent, it is offset from the upper-left of the parent element. @tparam string default_text The default text to have in the button -@tparam ?iguielement parent The parent element of the button. +@tparam? iguielement parent The parent element of the button. @treturn iguibutton The button element */ //gui.newbutton({{sx,sy},{ex,ey}},"text"[,parent]) diff --git a/src/client/lua_api/gui/iguicheckbox.cpp b/src/client/lua_api/gui/iguicheckbox.cpp index 6413883..365b75d 100644 --- a/src/client/lua_api/gui/iguicheckbox.cpp +++ b/src/client/lua_api/gui/iguicheckbox.cpp @@ -8,9 +8,6 @@ extern "C" { #include "iguielement.hpp" #include <shared/lua_api/common.hpp> -/*** -@module gui -*/ using namespace irr; using namespace gui; using namespace core; @@ -26,11 +23,11 @@ following fields, which they will call for callbacks: It may additionally call any @{iguielement} callbacks -@function newcheckbox() +@function gui.newcheckbox() @tparam rect dimensions The rectangle to place the box at. If the box has a parent, it is offset from the upper-left of the parent element. @tparam string default_text The default text to have in the edit box -@tparam ?iguielement parent The parent element of the edit box +@tparam? iguielement parent The parent element of the edit box @treturn iguieditbox The edit box element */ //new({startx,starty},{endx,endy},"checkbox_name"[,ud_parent]) @@ -59,6 +56,11 @@ int newiguicheckbox(lua_State* L){ return 1; } +/*** +Is the checkbox checked. +@function iguicheckbox:ischecked() +@treturn boolean Is this checkbox checked? +*/ //ischecked(self) int ischecked(lua_State *L){ lua_getfield(L,-1,"guielement"); @@ -69,6 +71,11 @@ int ischecked(lua_State *L){ return 1; } +/*** +Set the state of the checkbox. +@function iguicheckbox:setchecked(set) +@tparam boolean set Should this checkbox be checked? (false to uncheck) +*/ //setchecked(self, checked) int setchecked(lua_State *L){ int should = lua_toboolean(L,-1); diff --git a/src/client/lua_api/gui/iguicolorselector.cpp b/src/client/lua_api/gui/iguicolorselector.cpp index 8a61c6d..5a11394 100644 --- a/src/client/lua_api/gui/iguicolorselector.cpp +++ b/src/client/lua_api/gui/iguicolorselector.cpp @@ -10,9 +10,6 @@ extern "C" { #include "iguielement.hpp" #include <shared/lua_api/common.hpp> -/*** -@module gui -*/ using namespace irr; using namespace gui; using namespace core; @@ -20,10 +17,11 @@ using namespace core; extern IrrlichtDevice* device; /*** -@function newcolorselector() -Creates a new checkbox +Creates a new Color selector. +Creates a dialog box that allows the user to select a color. TODO:Broken? +@function gui.newcolorselector() @tparam string title The title for this color selector -@tparam ?iguielement parent The parent element of the edit box +@tparam? iguielement parent The parent element of the edit box @treturn iguicolorselector The color selector element */ //newcolorselector("title"[,parent]) @@ -61,6 +59,12 @@ static const luaL_reg iguicolorselector_m[] = { {0,0}, }; +/*** +A dialog that allows the user to select a color +@class iguicolorselector +@inherits guielement +*/ + int iguicolorselector_register(lua_State* L){// luaL_newmetatable(L,"gui.colorselector");//m{gui.checkbox} luaL_register(L,NULL,iguielement_m); diff --git a/src/client/lua_api/gui/iguicombobox.cpp b/src/client/lua_api/gui/iguicombobox.cpp index 43c66f1..a9c4137 100644 --- a/src/client/lua_api/gui/iguicombobox.cpp +++ b/src/client/lua_api/gui/iguicombobox.cpp @@ -11,9 +11,6 @@ extern "C" { #include <shared/lua_api/common.hpp>
#include <client/lua_api/gui/iguicombobox.hpp>
-/***
-@module gui
-*/
using namespace irr;
using namespace core;
using namespace gui;
@@ -24,10 +21,10 @@ extern IrrlichtDevice* device; Creates a new combo box.
Buttons may have the following fields set for callbacks:
`.onChange(self)`
-@function newcombobox()
+@function gui.newcombobox()
@tparam rect dimensions The rectangle to place the button at. If the box has a parent,
it is offset from the upper-left of the parent element.
-@tparam ?iguielement parent The parent element of the button.
+@tparam? iguielement parent The parent element of the button.
@treturn iguicombobox The combo box element
*/
//gui.newcombobox({{sx,sy},{ex,ey}}[,parent])
@@ -60,7 +57,15 @@ static int newiguicombobox(lua_State* L){ return 1;
}
-//{combobox}.addItem(self,text,id)
+/***
+Add an item to the combo box
+Adds an option to this combo box, with a given id for when it it selected
+@function iguicombobox:additem(text,id)
+@tparam string text The text to add to the combo box
+@tparam number id The id to return from getselected() when this option is
+selected
+*/
+//{combobox}.add(self,text,id)
int additem(lua_State *L){
int id = lua_tonumber(L,-1);
lua_pop(L,1);//self,text
@@ -78,6 +83,12 @@ int additem(lua_State *L){ return 0;
}
+/***
+Get the selected item.
+Returns the number for the selected item, set with add()
+@function iguicombobox:get()
+@treturn number The item number that is currently selected
+*/
// {combobox}.getselected(self)
int getselected(lua_State *L){
lua_getfield(L,-1,"guielement");//self,ud_guielement
@@ -88,7 +99,13 @@ int getselected(lua_State *L){ return 1;
}
-//{combobox}.removeitem(self,id)
+/***
+Remove an item
+Removes an item from the combo box at the given id. Id's are assigned with add()
+@function iguicombobox:remove()
+@tparam number id The id number of the item to remove
+*/
+//{combobox}.remove(self,id)
int removeitem(lua_State *L){
int idx = lua_tonumber(L,-1);//self,id
lua_pop(L,1);//self
@@ -105,9 +122,9 @@ static const luaL_reg iguicombobox_f[] = { };
static const luaL_reg iguicombobox_m[] = {
- {"addItem", additem},
- {"getSelected", getselected},
- {"removeItem", removeitem},
+ {"add", additem},
+ {"get", getselected},
+ {"remove", removeitem},
{0,0},
};
diff --git a/src/client/lua_api/gui/iguieditbox.cpp b/src/client/lua_api/gui/iguieditbox.cpp index 7de3f37..409c2fc 100644 --- a/src/client/lua_api/gui/iguieditbox.cpp +++ b/src/client/lua_api/gui/iguieditbox.cpp @@ -12,10 +12,6 @@ extern "C" { #include <shared/util/hashmap.hpp> #include <shared/lua_api/common.hpp> -/*** -@module gui -*/ - using namespace irr; using namespace core; using namespace gui; @@ -23,11 +19,11 @@ using namespace gui; extern IrrlichtDevice* device; /*** -@function neweditbox() -Creates a new text entry box +Creates a new text entry box. +@function gui.neweditbox() @tparam rect dimensions The rectangle to place the box at. If the box has a parent, it is offset from the upper-left of the parent element. -@tparam ?iguielement parent The parent element of the edit box -@tparam ?string default_text The default text to have in the edit box +@tparam? iguielement parent The parent element of the edit box +@tparam? string default_text The default text to have in the edit box @treturn iguieditbox The edit box element */ //gui.neweditbox({{sx,sy},{ex,ey}}[,parent][,"default text"]) @@ -73,6 +69,12 @@ static int newiguieditbox(lua_State* L){ return 1; } +/*** +Set the edit box to multiline mode. +Allow / disallow the edit box to accept newlines. +@function iguieditbox:setmultiline(enable) +@tparam boolean enable Should the edit box allow newlines? +*/ //self:setmultiline(bool_enabled) int set_multiline(lua_State *L){ int should = lua_toboolean(L,-1); diff --git a/src/client/lua_api/gui/iguielement.cpp b/src/client/lua_api/gui/iguielement.cpp index db7669a..17ec4a5 100644 --- a/src/client/lua_api/gui/iguielement.cpp +++ b/src/client/lua_api/gui/iguielement.cpp @@ -1,5 +1,5 @@ /*This file defines some things that all igui stuff can do*/ -/*** +/* All gui elements inherit from iguielement. Some functions (like settext()) do different things for different elements. All gui elements can call the following callbacks: @@ -9,7 +9,6 @@ All gui elements can call the following callbacks: onHover(self) onLeave(self) -@classmod iguielement */ extern "C" { #include <lua.h> @@ -28,9 +27,10 @@ using namespace core; using namespace gui; extern IrrlichtDevice *device; + /*** Move an element (by an offset) from it's current position -@function guielement:move() +@function iguielement:move() @tparam vector2d position The offset to move this element by */ //move({element},{x,y}) -> nil @@ -51,7 +51,7 @@ int moveiguielement(lua_State* L){ /*** Set the visibility of this element -@function guielement:setvisible() +@function iguielement:setvisible() @tparam boolean visible Should this element be visible? */ int setvisible(lua_State *L){ @@ -69,7 +69,7 @@ int setvisible(lua_State *L){ /*** Find the rectangle that an element occupies -@function guielement:getabsrect() +@function iguielement:getabsrect() @treturn rect The rectangle that this element occupies */ //getabsrect({element})-> {{sx,sy},{ex,ey}} @@ -91,7 +91,7 @@ int getiguiclippingrect(lua_State* L){ /*** Find the rectangle that an element occupies that is visible to the user -@function guielement:getabsclippingrect() +@function iguielement:getabsclippingrect() @treturn rect The rectangle that this element occupies that is visible to the user */ //getabsclippingrect({element}) :: {{sx,sy},{ex,ey}} @@ -112,7 +112,7 @@ int getiguiabsclippingrect(lua_State *L){ /*** Find the relative rectangle that this element occupies -@function guielement:getrelrect() +@function iguielement:getrelrect() @treturn rect The rectangle that this element occupies relative to it's parent */ int getiguirelrect(lua_State *L){ @@ -135,7 +135,7 @@ Sets the text of the element This function may do different things to different gui elements. For example, on a window, it sets the title. On a button, it sets the button's text. -@function guielement:settext() +@function iguielement:settext() @tparam string text The text to set on the element */ //setText({guielement},"text") :: nil @@ -168,7 +168,7 @@ int setrelrect(lua_State *L){ /*** -@function guielement:gettext() +@function iguielement:gettext() @treturn string The caption text of the element. For input element like editboxes, this returns the text that the edit box contains. */ @@ -189,7 +189,7 @@ int getiguitext(lua_State* L){ /*** Removes a gui element, and any child elements -@function guielement:remove() +@function iguielement:remove() */ //remove({self}) int removeiguielement(lua_State* L){ diff --git a/src/client/lua_api/gui/iguifiledialog.cpp b/src/client/lua_api/gui/iguifiledialog.cpp index d717673..9b789cb 100644 --- a/src/client/lua_api/gui/iguifiledialog.cpp +++ b/src/client/lua_api/gui/iguifiledialog.cpp @@ -17,9 +17,6 @@ extern "C" { #include <shared/util/hashmap.hpp> #include <shared/lua_api/common.hpp> -/*** -@module gui -*/ using namespace irr; using namespace core; using namespace gui; @@ -27,17 +24,17 @@ using namespace gui; extern IrrlichtDevice* device; /*** -@function newfileopendialog() Creates a new dialog to open a file. The file creation window may have the following fields set for callbacks: .onDirectorySelect(self) .onFileSelect(self) .onCanceled(self) -@tparam ?string title The rectangle to place the button at. If the box has a parent, +@function gui.newfileopendialog() +@tparam? string title The rectangle to place the button at. If the box has a parent, it is offset from the upper-left of the parent element. -@tparam ?string path The path to open the file dialog to -@tparam ?iguielement parent The parent element of the button. -@tparam ?boolean modal If other gui elements can be interacted with before this element is closed +@tparam? string path The path to open the file dialog to +@tparam? iguielement parent The parent element of the button. +@tparam? boolean modal If other gui elements can be interacted with before this element is closed @treturn iguifileopendialog The button element */ //gui.newfileopendialog(["title"][,"path"][,parent][,modal]) diff --git a/src/client/lua_api/gui/iguiimage.cpp b/src/client/lua_api/gui/iguiimage.cpp index 267cbd2..81f6568 100644 --- a/src/client/lua_api/gui/iguiimage.cpp +++ b/src/client/lua_api/gui/iguiimage.cpp @@ -17,9 +17,6 @@ extern "C" { #include "../../callbackhandeler.hpp" #include <shared/lua_api/common.hpp> -/*** -@module gui -*/ using namespace irr; using namespace video; using namespace gui; @@ -28,14 +25,14 @@ extern IrrlichtDevice* device; extern IGUIEnvironment* env; /*** -@function newiguiimage() +@function gui.newiguiimage() Creates a new guielement with an image. The size of the iguielement is the same as the itexture used for it's creation. @tparam vector2d position The upper-left hand corner of the element. it is offset from the upper-left of the parent element. @tparam number alpha The transparency of the element. @tparam itexture texture The texture to display on this element. -@tparam ?iguielement parent The parent element of the button. +@tparam? iguielement parent The parent element of the button. @treturn iguifileopendialog The button element */ //newiguiimage({startx,starty},alpha,{itexture}[,parent]) -> {guielement} @@ -70,6 +67,12 @@ static int newiguiimage(lua_State* L){ return 1; } +/*** +Set the color of the image +Sets the color offset (additive color) for the image. +@function iguiimage:setcolor(color c) +@tparam color color The color to set the image as +*/ //setcolor(self,{r,g,b,a}) int setcolor(lua_State* L){ long r,g,b,a; @@ -81,6 +84,12 @@ int setcolor(lua_State* L){ return 0; } +/*** +Set the image of the element +Sets the image for the element. TODO: Memory leak of old images? +@function iguiimage:setimage(itexture texture) +@tparam itexture texture The texture to set this image element to +*/ //setimage(self,itexture) int setimage(lua_State *L){ lua_getfield(L,-1,"texture");//{iguiimg},{itex} diff --git a/src/client/lua_api/gui/iguilabel.cpp b/src/client/lua_api/gui/iguilabel.cpp index 529d680..bcb1778 100644 --- a/src/client/lua_api/gui/iguilabel.cpp +++ b/src/client/lua_api/gui/iguilabel.cpp @@ -17,21 +17,18 @@ extern "C" { #include "../../callbackhandeler.hpp" #include <shared/lua_api/common.hpp> -/*** -@module gui -*/ using namespace irr; using namespace gui; extern IrrlichtDevice* device; /*** -@function newlabel() +@function gui.newlabel() Creates a new label to display text. @tparam rect pos The position of the label, reletive to the upper-left of it's parent element, or the root window if parent is nil. @tparam string text The text to display on this label. -@tparam ?iguielement parent The parent element of the button. +@tparam? iguielement parent The parent element of the button. @treturn iguilabel The label element */ //gui.newlabel({{sx,sy},{ex,ey}},"text"[,parent]) :: {guielement} diff --git a/src/client/lua_api/gui/iguispinbox.cpp b/src/client/lua_api/gui/iguispinbox.cpp index 7cb1775..25ecbde 100644 --- a/src/client/lua_api/gui/iguispinbox.cpp +++ b/src/client/lua_api/gui/iguispinbox.cpp @@ -12,9 +12,6 @@ extern "C" { #include <shared/util/hashmap.hpp> #include <shared/lua_api/common.hpp> -/*** -@module gui -*/ using namespace irr; using namespace core; using namespace gui; @@ -22,13 +19,13 @@ using namespace gui; extern IrrlichtDevice* device; /*** -@function newspinbox() +@function gui.newspinbox() Creates a new spinbox @tparam rect dimensions The rectangle to place the button at. If the box has a parent, it is offset from the upper-left of the parent element. -@tparam ?string default_text The default text to display in the spinbox. -@tparam ?iguielement parent The parent element of the button. -@tparam ?boolean border Display a border around the spinbox +@tparam? string default_text The default text to display in the spinbox. +@tparam? iguielement parent The parent element of the button. +@tparam? boolean border Display a border around the spinbox @treturn iguibutton The button element */ //gui.newspinbox({{sx,sy},{ex,ey}}[,"text"][,parent][,border]) diff --git a/src/client/lua_api/gui/iguitreeview.cpp b/src/client/lua_api/gui/iguitreeview.cpp index 68aa3cc..3778a50 100644 --- a/src/client/lua_api/gui/iguitreeview.cpp +++ b/src/client/lua_api/gui/iguitreeview.cpp @@ -11,25 +11,21 @@ extern "C" { #include "client/callbackhandeler.hpp" #include <shared/lua_api/common.hpp> -/*** -@module gui -*/ using namespace irr; using namespace core; using namespace gui; - extern IrrlichtDevice* device; /*** -@function newtreeview() +@function gui.newtreeview() Creates a new tree view @tparam dimensions rect The rectangle to place the tree view at. If the box has a parent, it is offset from the upper-left of the parent element. -@tparam ?iguielement parent The parent element of the button. -@tparam ?boolean draw_background Should we draw a background for the tree view? -@tparam ?boolean vertical_scroll Should there be a vertical scroll bar? -@tparam ?boolean horizonal_scroll Should there be a horizontal scroll bar? +@tparam? iguielement parent The parent element of the button. +@tparam? boolean draw_background Should we draw a background for the tree view? +@tparam? boolean vertical_scroll Should there be a vertical scroll bar? +@tparam? boolean horizonal_scroll Should there be a horizontal scroll bar? @treturn iguitreeview The tree view element */ //gui.newtreeview({{sx,sy},{ex,ey}},[,parent][,draw_background][,vertical_scroll][,horizontal_scroll]) diff --git a/src/client/lua_api/gui/iguiwindow.cpp b/src/client/lua_api/gui/iguiwindow.cpp index 236fd5d..70f26e4 100644 --- a/src/client/lua_api/gui/iguiwindow.cpp +++ b/src/client/lua_api/gui/iguiwindow.cpp @@ -17,18 +17,15 @@ extern "C" { #include "../../callbackhandeler.hpp" #include <shared/lua_api/common.hpp> -/*** -@module gui -*/ using namespace irr; using namespace gui; /*** -@function newwindow() Creates a new gui window . +@function gui.newwindow() @tparam rect dimensions The rectangle to create the window at. @tparam string title_text The text to show in the title bar of the window -@tparam ?iguielement parent The parent element of the window. +@tparam? iguielement parent The parent element of the window. @treturn iguiwindow The window element In return to the usual gui element calls, IGUI window may call a `onClose()` callback. @@ -84,6 +81,11 @@ static const luaL_reg iguiwindow_m[] = { {0, 0}, }; +/*** +A window that you can add other gui elements to. +@class iguiwindow +@inherits iguielement +*/ int iguiwindow_register(lua_State* L, IrrlichtDevice* d){ luaL_newmetatable(L,"gui.window");//m{gui.window} lua_newtable(L); diff --git a/src/client/lua_api/io/ifilesystem.cpp b/src/client/lua_api/io/ifilesystem.cpp index 252b61b..12aab78 100644 --- a/src/client/lua_api/io/ifilesystem.cpp +++ b/src/client/lua_api/io/ifilesystem.cpp @@ -1,8 +1,5 @@ #include "ifilesystem.hpp" -/*** -@module io -*/ using namespace irr; using namespace io; @@ -11,7 +8,7 @@ extern IrrlichtDevice* device; /*** A list of files in the current direcotry. -@function list() +@function io.list() @treturn array The files and directories in the current directory. */ // io.list() @@ -36,7 +33,7 @@ int listfilesin(lua_State *L){ /*** Changes the current directory of the program -@function cd(dir) +@function io.cd(dir) @tparam string dir The directory to change to */ // io.cd("directory") @@ -52,10 +49,10 @@ int changedirectory(lua_State *L){ Logs some text with Irrlicht. `level` may be any of: io.LOG_DEBUG, io.LOG_INFO, io.LOG_WARN, io.LOG_ERROR, io.LOG_NONE -@function log(text,level[,hint]) +@function io.log(text,level[,hint]) @tparam string text The text to log @tparam log_level_enum level The log level -@tparam string hint An optional hint to supply with the log +@tparam? string hint An optional hint to supply with the log */ // io.log("text",level) // io.log("text",level[,"hint"]) @@ -83,7 +80,7 @@ int logmessage(lua_State *L){ Sets what output gets logged, and what gets ignored. level may be any of: io.LOG_DEBUG, io.LOG_INFO, io.LOG_WARN, io.LOG_ERROR, io.LOG_NONE -@function set_log_level(level) +@function io.set_log_level(level) @tparam number level the minimul level of log to capture */ //io.set_log_level(level) @@ -120,14 +117,35 @@ void ifilesystem_register(lua_State* L){ lua_getglobal(L,"io");//{io} luaL_register(L,NULL,ifilesystem_f); +/*** +Debugging log level +@field io.LOG_DEBUG +*/ lua_pushnumber(L,ELL_DEBUG); lua_setfield(L,-2,"LOG_DEBUG"); +/*** +Informational log level +@field io.LOG_INTO +*/ lua_pushnumber(L,ELL_INFORMATION); lua_setfield(L,-2,"LOG_INFO"); +/*** +Warning log level +@field io.LOG_WARN +*/ lua_pushnumber(L,ELL_WARNING); lua_setfield(L,-2,"LOG_WARN"); +/*** +Error log level +@field io.LOG_ERROR +*/ lua_pushnumber(L,ELL_ERROR); lua_setfield(L,-2,"LOG_ERROR"); +/*** +Nonetype log level. +Use this with @{io#set_log_level} if you don't want to log anything. +@field io.LOG_NONE +*/ lua_pushnumber(L,ELL_NONE); lua_setfield(L,-2,"LOG_NONE"); diff --git a/src/client/lua_api/load_gui.cpp b/src/client/lua_api/load_gui.cpp index 64b9711..18fe78f 100644 --- a/src/client/lua_api/load_gui.cpp +++ b/src/client/lua_api/load_gui.cpp @@ -1,6 +1,5 @@ -/*** +/* Utilities for drawing GUI things on the screen -@module gui */ #include <stdio.h> @@ -47,11 +46,19 @@ int screenheight(lua_State* L); int getroot(lua_State *L); /*** +Get the width of the screen. +Get the width of the screen in pixels. This should have been set with the options +in @{deviceinit.lua}, but may change of the course of the application's life (ex, +if the user resizes the screen) @function gui.scrw() @treturn number The width of the screen */ /*** +Get the height of the screen. +Get the height of the screen in pixels. This should have been set with the options +in @{deviceinit.lua}, but may change of the course of the application's life (ex, +if the user resizes the screen) @function gui.scrh() @treturn number The height of the screen */ diff --git a/src/client/lua_api/load_scene.cpp b/src/client/lua_api/load_scene.cpp index c605581..f64fc26 100644 --- a/src/client/lua_api/load_scene.cpp +++ b/src/client/lua_api/load_scene.cpp @@ -11,8 +11,10 @@ extern "C" { #include "scene/icamera.hpp" #include "scene/imesh.hpp" #include "scene/ilight.hpp" +#include <shared/lua_api/common.hpp> using namespace irr; +using namespace video; extern IrrlichtDevice* device; @@ -25,6 +27,9 @@ void load_scenefuncs(lua_State* L){ imesh_register(L); ilight_register(L); + //INode flags + set_const(L,EMF_WIREFRAME); + //lua_pop(L, 1); } diff --git a/src/client/lua_api/scene/icamera.cpp b/src/client/lua_api/scene/icamera.cpp index 003f2ad..34b3447 100644 --- a/src/client/lua_api/scene/icamera.cpp +++ b/src/client/lua_api/scene/icamera.cpp @@ -22,6 +22,20 @@ using namespace core; extern IrrlichtDevice* device; +/*** +Create a maya camera +Creates a camera that can be controlled with maya style controls by default, +click and drag rotates the camera, while right click and mouse up/down zooms +in or out. +@function scene.newmayacamera() +@treturn iscenemayacamera +*/ +/*** +A maya camera. +A camera that can be controlled similar to the 3d modeling software "Maya" +@class iscenemayacamera +@inherits iscenecamera +*/ static int newiscenemayacamera(lua_State* L){ printf("createing maya camera!\n"); ISceneManager* smgr = device->getSceneManager(); @@ -38,6 +52,20 @@ static int newiscenemayacamera(lua_State* L){ return 1; } +/*** +Create an fps camera. +Create a camera with default first person shooter controls. The camera and +be rotated with the mouse, and moved with the arrow keys. +@function scene.newfpscamera() +@treturn iscenefpscamera The camera +*/ +/*** +A camera with default FPS controls +An FPS camera can be controlled with the arrow keys, and rotated with the mouse +by default. +@class iscenefpscamera +@inherits iscenecamera +*/ // ifpscamera.new() static int newiscenefpscamera(lua_State* L){// ISceneManager* smgr = device->getSceneManager(); @@ -60,6 +88,21 @@ static int newiscenefpscamera(lua_State* L){// return 1; } +/*** +Create a new camera +Creates a new camera at the given position. +@function scene.newiscenecamera(vector3d position, vector3d lookat, iscenenode parent) +@tparam vector3d position The position to create the camera in +@tparam vector3d lookat A vector for the camera to look at. Use this to set it's rotation. +@tparam? iscenenode parent A node to parent this camera to. If the parent moves, the camera will move with it. +@treturn iscenecamera The camera +*/ +/*** +A camera. +The world is rendered through cameras. +@class iscenecamera +@inherits iscenenode +*/ //iscenecamera.new(Vector position, Vector lookat,{node=parent}) static int newiscenecamera(lua_State* L){ printf("Createing camera!\n"); @@ -98,6 +141,12 @@ static int newiscenecamera(lua_State* L){ return 1; } +/*** +Lock on +Should the camera be locked on to something? +@function iscenecamera:bindtarget(boolean bind) +@tparam boolean bind Should the camera be locked on to it's "lookat"? +*/ //camera:bind_target(bool) :: nil static int icamerabindtarget(lua_State *L){ int should_bind = lua_toboolean(L,-1);//{node=ud_cam},bool_shouldbind @@ -110,6 +159,12 @@ static int icamerabindtarget(lua_State *L){ return 0; } +/*** +Gets the target of a camera +Gets the vector that a camera is looking at +@function iscenecamera:gettarget() +@treturn vector3d The vector that the camera is looking at +*/ //camera:gettarget() :: v3f static int icameragettarget(lua_State *L){ lua_getfield(L,-1,"node"); @@ -120,6 +175,12 @@ static int icameragettarget(lua_State *L){ return 1; } +/*** +Set the camera's target +Forcefully set the rotation the camera should be looking +@function iscenecamera:settarget(vector3d target) +@tparam vector3d target The vector that the camera should be looking at +*/ //camera:settarget(v3f) static int icamerasettarget(lua_State *L){ double x,y,z; diff --git a/src/client/lua_api/scene/igeneric.cpp b/src/client/lua_api/scene/igeneric.cpp index dcac022..a0c33b3 100644 --- a/src/client/lua_api/scene/igeneric.cpp +++ b/src/client/lua_api/scene/igeneric.cpp @@ -14,14 +14,8 @@ using namespace core; using namespace scene; using namespace video; -/*** -@classmod iscenenode -*/ - extern IrrlichtDevice* device; - - /*** Get the position of a scene element. @function iscenenode:getpos() @@ -82,13 +76,74 @@ int iscenesetangle(lua_State* L){//{node=ud_ISceneNode},{x,y,z} } /*** +Gets the material of a scene element. +To check if to materials are equal, compare their .texture fields, these hold +a light userdata. +@function iscenenode:getmaterial() +@treturn smaterial The material that was applied to this node +*/ +//iscenenode:getmaterial({node=ud_ISceneNode},texture_number=0) :: {texture=ud_itexture} +int iscenegetmaterial(lua_State *L){ + int args = lua_gettop(L); + u32 layer = 0; + if(args == 2){ + layer = lua_tonumber(L,-1); + lua_pop(L,1); + } + lua_getfield(L,-1,"node"); + ISceneNode *i = (ISceneNode*)lua_touserdata(L,-1); + lua_pop(L,2);// + SMaterial mat = i->getMaterial(layer); + ITexture *tex = mat.getTexture(0); + printf("got texutre:%p\n",(void*)tex); + lua_newtable(L);//{} + lua_pushlightuserdata(L,tex);//{},ud_texture + lua_setfield(L,-2,"texture");//{material} + luaL_getmetatable(L,"video.smaterial");//{material},{material_m} + lua_setmetatable(L,-2);//{material} + return 1; +} + +/*** +Gets the number of materials on a scene node. +@function iscenenode:getmaterialcount() +@treturn number The number of materials on this node +*/ +//iscenenode:getmaterialcount() +int iscenegetmaterialcount(lua_State *L){ + lua_getfield(L,-1,"node"); + ISceneNode *i = (ISceneNode*)lua_touserdata(L,-1); + lua_pop(L,2);// + u32 count = i->getMaterialCount(); + lua_pushnumber(L,count); + return 1; +} + +/*** +Sets a flag on the material +@function iscenenode:setmaterialflag(flag,on) +@tparam number flag The flag to modify +@tparam boolean on Should the flag be set +*/ +//iscenenode:setmaterialflag(flag,on) +int iscenesetmaterialflag(lua_State *L){ + int on = lua_toboolean(L,-1); + E_MATERIAL_FLAG flag = (E_MATERIAL_FLAG)lua_tonumber(L,-2); + lua_pop(L,2); + lua_getfield(L,-1,"node"); + ISceneNode *i = (ISceneNode*)lua_touserdata(L,-1); + lua_pop(L,2);// + i->setMaterialFlag(flag,on == 1); + return 0; +} + +/*** Set the mateiral of a scene element. @function iscenenode:setmaterial() @tparam texture texture The texture to apply to this material */ //iscenesetmaterialtexture({node=ud_ISceneNode},{texture=ud_itexture},texture_number=0) int iscenesetmaterial(lua_State *L){ - printf("Calling generic iscenesetmaterial function\n"); int args = lua_gettop(L); u32 layer = 0; if(args == 3){ @@ -220,6 +275,9 @@ extern const luaL_reg igeneric_m[] = { {"getang", iscenegetangle}, {"setang", iscenesetangle}, {"setmaterialtexture", iscenesetmaterial}, + {"getmaterial", iscenegetmaterial}, + {"getmaterialcount", iscenegetmaterialcount}, + {"setmaterialflag", iscenesetmaterialflag}, {"getname", iscenegetname}, {"setname", iscenesetname}, {"setscale", iscenesetscale}, diff --git a/src/client/lua_api/scene/ilight.cpp b/src/client/lua_api/scene/ilight.cpp index 1e292ee..e405443 100644 --- a/src/client/lua_api/scene/ilight.cpp +++ b/src/client/lua_api/scene/ilight.cpp @@ -23,6 +23,21 @@ using namespace core; extern IrrlichtDevice* device; +/*** +Create a light +Creates a light that illuminates the surrounding objects dynamically. +@function scene.newlight(number radius, vector3d position) +@tparam number radius The radius that the light should shine +@tparam vector3d position The position to create the light at +@treturn iscenelight The created light +*/ +/*** +A light. +Lights illuminate the scene nodes arounded them based on mesh vertexes. You +probably want to bake the lightmap instead of using light nodes. +@class iscenelight +@inherits iscenenode +*/ //{} :: scene.newlight(radius, {v3 position}) static int newiscenelight(lua_State* L){ printf("Createing light!\n"); @@ -48,6 +63,12 @@ static int newiscenelight(lua_State* L){ } +/*** +Sets the light type +Different light types illuminate the surrounding meshes in different ways. +@function iscenelight:settype(number type) +@tparam number type The type the light should be +*/ //settype(self,const) int settype(lua_State *L){ video::E_LIGHT_TYPE type = (video::E_LIGHT_TYPE)lua_tonumber(L,-1);//self,type @@ -60,8 +81,6 @@ int settype(lua_State *L){ } static const luaL_reg ilight_m[] = { - {"getpos", iscenegetpos}, - {"setpos", iscenesetpos}, {"settype", settype}, {0, 0}, }; @@ -72,8 +91,20 @@ void ilight_register(lua_State* L){ lua_pushcfunction(L,newiscenelight);//{scene},newiscenelight() lua_setfield(L,-2,"newlight");//{scene} +/*** +A point light +@field scene.ELT_POINT +*/ set_const(L,ELT_POINT); +/*** +A spot light +@field scene.ELT_SPOT +*/ set_const(L,ELT_SPOT); +/*** +A sun light +@field scene.ELT_DIRECTIONAL +*/ set_const(L,ELT_DIRECTIONAL); lua_pop(L,1);// @@ -81,6 +112,7 @@ void ilight_register(lua_State* L){ luaL_newmetatable(L,"scene.ilight");//scene.ilight lua_newtable(L);//scene.ilight,{} luaL_register(L, NULL, ilight_m);//scene.ilight,{} + luaL_register(L, NULL, igeneric_m); lua_setfield(L,-2,"__index");//scene.ilight lua_pop(L,1); diff --git a/src/client/lua_api/scene/imesh.cpp b/src/client/lua_api/scene/imesh.cpp index 8ed357c..479da15 100644 --- a/src/client/lua_api/scene/imesh.cpp +++ b/src/client/lua_api/scene/imesh.cpp @@ -16,9 +16,6 @@ extern "C" { #include "igeneric.hpp" #include <shared/lua_api/common.hpp> -/*** -@module scene -*/ using namespace irr; using namespace scene; using namespace core; diff --git a/src/client/lua_api/video/iimage.cpp b/src/client/lua_api/video/iimage.cpp index 4c7795d..3655b64 100644 --- a/src/client/lua_api/video/iimage.cpp +++ b/src/client/lua_api/video/iimage.cpp @@ -4,10 +4,6 @@ #include <shared/lua_api/common.hpp> -/*** -@module video -*/ - using namespace irr; using namespace video; @@ -17,7 +13,7 @@ extern IVideoDriver* driver; /*** Creates a new irrlicht image. A newly created image will be fully white by default. -@function newiimage(format, size) +@function video.newiimage(format, size) @tparam enum_color_format format The format for the image @tparam vec2d size The size of the image @treturn iimage The image @@ -44,7 +40,7 @@ int newiimage(lua_State* L){ Creates a new irrlicht image. Creates a new irrlicht image from a file. The format and width/height will be taken from the image file. -@function newiimagefromfile(path) +@function video.newiimagefromfile(path) @tparam string path The file path of the image file @treturn iimage The loaded image */ @@ -138,7 +134,7 @@ int getiimagepixel(lua_State* L){ /*** Returns the dimensions of the image @function iimage:getDimensions() -@treturn vec2i dimensions The dimensions of the image +@treturn vec2i The dimensions of the image */ //getdimensions({self}) int getiimagedimensions(lua_State *L){ @@ -162,10 +158,29 @@ void iimage_register(lua_State* L){ driver = device->getVideoDriver(); lua_getglobal(L,"video");//{} +/*** +1 bit alpha, 5 bits red, blue, and green (16 bit) +@field video.ECF_A1R5G5B5 +*/ set_const(L,ECF_A1R5G5B5); +/*** +5 bit red, 6 bit green, 5 bit blue +@field video.ECF_R5G6B5 +*/ set_const(L,ECF_R5G6B5); +/*** +8 bit red, blue, green, and alpha +@field video.ECF_A8R8G8B8 +*/ set_const(L,ECF_A8R8G8B8); +/*** +1 channel with 16 bit floating point. +1 channel 16 bit floating point. Uses the red channel. Floating point images may only be used for render targets. +@field video.ECF_R16F +@see @{render_targets} +*/ set_const(L,ECF_R16F); +//TODO: finish documenting these set_const(L,ECF_G16R16F); set_const(L,ECF_A16B16G16R16F); set_const(L,ECF_R32F); diff --git a/src/client/lua_api/video/smaterial.cpp b/src/client/lua_api/video/smaterial.cpp index 510748c..4ed6a46 100644 --- a/src/client/lua_api/video/smaterial.cpp +++ b/src/client/lua_api/video/smaterial.cpp @@ -9,7 +9,15 @@ extern "C" { using namespace irr::video; -/*This probably needs a _gc metamethod*/ +/*** +Creates a new material. +Creates a new material that can then be used on an @{iscenenode} +WARNING: this item is not currently garbage collected, be careful not to make +more smaterials than you need. +@function video.newsmaterial() +@treturn smaterial The new material +*/ +/*TODO: This probably needs a _gc metamethod*/ //newsmaterial() int newsmaterial(lua_State* L){ @@ -24,6 +32,14 @@ int newsmaterial(lua_State* L){ return 1; } +/*** +Sets a texture for this material. +Sets a texture for the material on the given index. For more information on +what each texture of a material does, see the irrlicht documentation. +@function smaterial:settexture(index,texture) +@tparam number index The index of the texture in the material +@tparam itexture texture The texture to use +*/ //setTexture(self,int_num,{ITexture texture}) int setTexture(lua_State* L){ lua_getfield(L,-1,"texture"); @@ -38,6 +54,13 @@ int setTexture(lua_State* L){ return 0; } +/*** +Sets a flag on this material. +Sets the given flag on the material +@function smaterial:setflag(flag,state) +@tparam number flag The flag to set, see @{video} for flags. +@tparam boolean state The state to set the flag in +*/ //{Material},flag,state int setFlag(lua_State* L){ int b = lua_toboolean(L,-1);//{material},flag,state @@ -52,8 +75,8 @@ int setFlag(lua_State* L){ } static const luaL_reg smaterial_m[] = { - {"setTexture", setTexture}, - {"setFlag", setFlag}, + {"settexture", setTexture}, + {"setflag", setFlag}, {0,0}, }; @@ -73,6 +96,30 @@ void smaterial_register(lua_State* L){ lua_getglobal(L,"video");//{} + /*** + A table of constants for the material class. + @field EMF_WIREFRAME - enable wireframe + @field EMF_POINTCLOUD - displays the texture as a pointcloud instead of a solid face + @field EMF_GOURAUD_SHADING + @field EMF_LIGHTING + @field EMF_ZBUFFER + @field EMF_ZWRITE_ENABLE + @field EMF_BACK_FACE_CULLING + @field EMF_FRONT_FACE_CULLING + @field EMF_BILINEAR_FILTER + @field EMF_TRILINEAR_FILTER + @field EMF_ANISOTROPIC_FILTER + @field EMF_FOG_ENABLE + @field EMF_NORMALIZE_NORMALS + @field EMF_TEXTURE_WRAP + @field EMF_ANTI_ALIASING + @field EMF_COLOR_MASK + @field EMF_COLOR_MATERIAL + @field EMF_USE_MIP_MAPS + @field EMF_BLEND_OPERATION + @field EMF_POLYGON_OFFSET + @table .video. + */ set_const(L,EMF_WIREFRAME); set_const(L,EMF_POINTCLOUD); set_const(L,EMF_GOURAUD_SHADING); |
