---++!! !EBookAppDev __description__: 娴忚銆侀槄璇汇€佸埗浣?D鐢靛瓙涔︺€?D鐢靛瓙涔︾敱鐜╁鍒涗綔鐨勬枃瀛楋紝鍥剧墖锛屽0闊筹紝3D涓栫晫缁勬垚銆?鐢ㄦ埛鍙互鐢ㄥ畠鍒朵綔App甯姪鍜岃鏄庝功锛岃春鍗★紝鐩稿唽绛夌瓑锛屽彂甯冨悗鍙互鍜屾湅鍙嬪叡浜€ %TOC{title="Contents:"}% %STARTINCLUDE% ---++ EBook app for Paraworld | *Title* | EBook app for Paraworld | | *Author(s)* | LiXizhi | | *Date* | 2008/1/5 | | *File* | script/kids/3DMapSystemUI/EBook/app_main.lua | ---+++ Description ---++ show the Ebook window <verbatim> Map3DSystem.App.Commands.Call("File.EBook"); </verbatim> replace "MyCompany.Apps" with whatever your name db registration insert script INSERT INTO apps VALUES (NULL, 'EBook_GUID', 'EBook', '1.0.0', 'http://www.paraengine.com/apps/EBook_v1.zip', 'YourCompany', 'enUS', 'script/kids/3DMapSystemUI/EBook/IP.xml', '', 'script/kids/3DMapSystemUI/EBook/app_main.lua', 'MyCompany.Apps.EBook.MSGProc', 1); %T% __Sample Code__ <verbatim> NPL.load("(gl)script/kids/3DMapSystemUI/EBook/app_main.lua"); </verbatim> ---+++ Member Functions ---++++ !MyCompany.Apps.EBook.OnConnection requires create class commonlib.setfield("MyCompany.Apps.EBook", {}); ------------------------------------------- event handlers ------------------------------------------- OnConnection method is the obvious point to place your UI (menus, mainbars, tool buttons) through which the user will communicate to the app. This method is also the place to put your validation code if you are licensing the add-in. You would normally do this before putting up the UI. If the user is not a valid user, you would not want to put the UI into the IDE. * _param_ __app__ : the object representing the current application in the IDE. * _param_ __connectMode__ : type of Map3DSystem.App.ConnectMode. __syntax__ <verbatim>function MyCompany.Apps.EBook.OnConnection(app, connectMode)</verbatim> __parameters__ | *app* | the object representing the current application in the IDE. | | *connectMode* | | ---++++ !MyCompany.Apps.EBook.OnDisconnection Receives notification that the Add-in is being unloaded. __syntax__ <verbatim>function MyCompany.Apps.EBook.OnDisconnection(app, disconnectMode)</verbatim> __parameters__ | *app* | | | *disconnectMode* | | ---++++ !MyCompany.Apps.EBook.OnQueryStatus This is called when the command's availability is updated When the user clicks a command (menu or mainbar button), the QueryStatus event is fired. The QueryStatus event returns the current status of the specified named command, whether it is enabled, disabled, or hidden in the CommandStatus parameter, which is passed to the msg by reference (or returned in the event handler). * _param_ __commandName__ : The name of the command to determine state for. Usually in the string format "Category.SubCate.Name". * _param_ __statusWanted__ : what status of the command is queried. it is of type Map3DSystem.App.CommandStatusWanted * _return_ ____ : returns according to statusWanted. it may return an integer by adding values in Map3DSystem.App.CommandStatus. __syntax__ <verbatim>function MyCompany.Apps.EBook.OnQueryStatus(app, commandName, statusWanted)</verbatim> __parameters__ | *app* | | | *commandName* | The name of the command to determine state for. Usually in the string format "Category.SubCate.Name". | | *statusWanted* | | | *return* | returns according to statusWanted. it may return an integer by adding values in Map3DSystem.App.CommandStatus. | ---++++ !MyCompany.Apps.EBook.OnExec This is called when the command is invoked.The Exec is fired after the QueryStatus event is fired, assuming that the return to the statusOption parameter of QueryStatus is supported and enabled. This is the event where you place the actual code for handling the response to the user click on the command. * _param_ __commandName__ : The name of the command to determine state for. Usually in the string format "Category.SubCate.Name". __syntax__ <verbatim>function MyCompany.Apps.EBook.OnExec(app, commandName, params)</verbatim> __parameters__ | *app* | | | *commandName* | The name of the command to determine state for. Usually in the string format "Category.SubCate.Name". | | *params* | | ---++++ !MyCompany.Apps.EBook.OnRenderBox Change and render the 3D world with mcml data that is usually retrieved from the current user's profile page for this application. __syntax__ <verbatim>function MyCompany.Apps.EBook.OnRenderBox(mcmlData)</verbatim> __parameters__ | *mcmlData* | | ---++++ !MyCompany.Apps.EBook.Navigate called when the user wants to nagivate to the 3D world location relavent to this application __syntax__ <verbatim>function MyCompany.Apps.EBook.Navigate()</verbatim> ---++++ !MyCompany.Apps.EBook.GotoHomepage called when user clicks to check out the homepage of this application. Homepage usually includes: developer info, support, developer worlds information, app global news, app updates, all community user rating, active users, trade, currency transfer, etc. __syntax__ <verbatim>function MyCompany.Apps.EBook.GotoHomepage()</verbatim> ---++++ !MyCompany.Apps.EBook.DoQuickAction called when user clicks the quick action for this application. __syntax__ <verbatim>function MyCompany.Apps.EBook.DoQuickAction()</verbatim> ---++++ !MyCompany.Apps.EBook.OnActivateDesktop Add terrain, sky and ocean button to the toolbar. __syntax__ <verbatim>function MyCompany.Apps.EBook.OnActivateDesktop(app)</verbatim> __parameters__ | *app* | | ---++++ !MyCompany.Apps.EBook.OnDeactivateDesktop __syntax__ <verbatim>function MyCompany.Apps.EBook.OnDeactivateDesktop()</verbatim> ---++++ !MyCompany.Apps.EBook.MSGProc ------------------------------------------- client world database function helpers. ------------------------------------------- ------------------------------------------ all related messages ------------------------------------------ ----------------------------------------------------- APPS can be invoked in many ways: Through app Manager mainbar or menu command or buttons Command Line 3D World installed apps ----------------------------------------------------- __syntax__ <verbatim>function MyCompany.Apps.EBook.MSGProc(window, msg)</verbatim> __parameters__ | *window* | | | *msg* | | ---++ EBook main window | *Title* | EBook main window | | *Author(s)* | LiXizhi | | *Date* | 2007/4/12 | | *File* | script/kids/3DMapSystemUI/EBook/EBook.lua | ---+++ Description %T% __Sample Code__ <verbatim> NPL.load("(gl)script/kids/3DMapSystemUI/EBook/EBook.lua"); EBook.Show; </verbatim> ---+++ Member Functions ---++++ !EBook.Show common control library NPL.load("(gl)script/ide/common_control.lua"); NPL.load("(gl)script/kids/3DMapSystemUI/EBook/EBook_db.lua"); NPL.load("(gl)script/kids/3DMapSystemUI/EBook/EBook_MainMenu.lua"); NPL.load("(gl)script/kids/3DMapSystemUI/EBook/EBook_MediaMenu.lua"); local L = CommonCtrl.Locale("ParaWorld"); if(not EBook) then EBook={}; end properties EBook.default_book = L"Default Book"; EBook.last_voice_file = nil; -- last played voicefile EBook.last_music_file = nil; -- last played music file if the current book is a zipped book, we will completed disable book editing functions. EBook.bIsZipBook = false; width of text control EBook.TextContentWidth = 260; the index of the first book in the EBook.allbooks. firstbook is shown as the first book in the current book page EBook.firstbookIndex = 1; how many books to be displayed on the single screen. EBook.MaxBookPerScreen = 4; an array all books sorted by name EBook.allbooks = {}; appearance EBook.main_bg = "Texture/kidui/explorer/bg.png" EBook.panel_bg = "Texture/kidui/explorer/panel_bg.png" EBook.panel_sub_bg = "Texture/kidui/explorer/panel_sub_bg.png" EBook.button_bg = "Texture/kidui/explorer/button.png" EBook.listbox_bg = "Texture/kidui/explorer/listbox_bg.png" EBook.dropdownarrow_bg = "Texture/kidui/explorer/dropdown_arrow.png" EBook.dropdownlist_cont_bg = "Texture/kidui/explorer/editbox256x32.png" EBook.editbox_bg = "Texture/kidui/explorer/editbox128x32.png" EBook.editbox_long_bg = "Texture/kidui/explorer/editbox256x32.png" * _param_ __bShow__ : show or hide the panel * _param_ ____ :_parent: parent window inside which the content is displayed. it can be nil. __syntax__ <verbatim>function EBook.Show(bShow, _parent, parentWindow)</verbatim> __parameters__ | *bShow* | show or hide the panel | | *parent* | | | *parentWindow* | | ---++++ !EBook.OnDestory destory the control __syntax__ <verbatim>function EBook.OnDestory()</verbatim> ---++++ !EBook.OnClickMainMenu click to show the mainmenu __syntax__ <verbatim>function EBook.OnClickMainMenu()</verbatim> ---++++ !EBook.OnClickMediaMenu click to show the media menu __syntax__ <verbatim>function EBook.OnClickMediaMenu()</verbatim> ---++++ !EBook.OnClickNewPage_Btn create a new page just after the current page. __syntax__ <verbatim>function EBook.OnClickNewPage_Btn()</verbatim> ---++++ !EBook.OnClickRemovePage_Btn remove the current page. __syntax__ <verbatim>function EBook.OnClickRemovePage_Btn()</verbatim> ---++++ !EBook.OnClickEditPageTitle call this to edit the page text __syntax__ <verbatim>function EBook.OnClickEditPageTitle()</verbatim> ---++++ !EBook.OnClickEditPageText call this to edit the page text __syntax__ <verbatim>function EBook.OnClickEditPageText()</verbatim> ---++++ !EBook.OnGotoPage * _param_ __pageNumber__ : error message is displayed if invalid page number. __syntax__ <verbatim>function EBook.OnGotoPage(pageNumber)</verbatim> __parameters__ | *pageNumber* | error message is displayed if invalid page number. | ---++++ !EBook.OnClickOpenBook call open use click the book icon * _param_ __nIndex__ : book icon index, normally 1-4 __syntax__ <verbatim>function EBook.OnClickOpenBook(nIndex)</verbatim> __parameters__ | *nIndex* | book icon index, normally 1-4 | ---++++ !EBook.OnTreeViewOpenBook open book __syntax__ <verbatim>function EBook.OnTreeViewOpenBook(treeNode)</verbatim> __parameters__ | *treeNode* | | ---++++ !EBook.OpenBook --------------------------------- update method --------------------------------- call this function to open a certain book by name. __syntax__ <verbatim>function EBook.OpenBook(bookname)</verbatim> __parameters__ | *bookname* | | ---++++ !EBook.UpdateBookShelf call this function to update book list on the bookshelf * _param_ __refreshBookList__ : if this is true, EBook.allbooks will be refreshed from the disk file. __syntax__ <verbatim>function EBook.UpdateBookShelf(refreshBookList)</verbatim> __parameters__ | *refreshBookList* | if this is true, EBook.allbooks will be refreshed from the disk file. | ---++++ !EBook.UpdatePage call this if the current book is changed. __syntax__ <verbatim>function EBook.UpdatePage()</verbatim> ---++++ !EBook.UpdatePageMedia call this if the page media is changed. __syntax__ <verbatim>function EBook.UpdatePageMedia()</verbatim> ---++++ !EBook.UpdatePageText call this if the current page text is changed. __syntax__ <verbatim>function EBook.UpdatePageText()</verbatim> ---++++ !EBook.PlayPageAudio called to play the page music associated with the page. __syntax__ <verbatim>function EBook.PlayPageAudio()</verbatim> ---++++ !EBook.LockBook make the book read-only or not. * _param_ __bLock__ :, if nil it will be toggled. __syntax__ <verbatim>function EBook.LockBook(bLock)</verbatim> __parameters__ | *bLock* | , if nil it will be toggled. | ---++++ !EBook.ResetBookWorld ----------------------------------------- in-game related functions ----------------------------------------- this function is called immediately after the book world is loaded. it will reset the player position and movie clips for the world associated with the current book page. * _param_ __bShow__ : boolean to show or hide the necessary book world UI. if nil, it will toggle current setting. __syntax__ <verbatim>function EBook.ResetBookWorld(bShow)</verbatim> __parameters__ | *bShow* | boolean to show or hide the necessary book world UI. if nil, it will toggle current setting. | ---++++ !EBook.OnClickReturnToBookBtn called when the user click the return to book button. TODO: maybe in future, I shall use a popup menu instead of a single button in the game. __syntax__ <verbatim>function EBook.OnClickReturnToBookBtn()</verbatim> ---++++ !EBook.OnClickEnterPageWorld on click the page world __syntax__ <verbatim>function EBook.OnClickEnterPageWorld()</verbatim> ---++++ !EBook.OnClickHelp open the help book __syntax__ <verbatim>function EBook.OnClickHelp()</verbatim> ---++ The EBook Database | *Title* | The EBook Database | | *Author(s)* | LiXizhi | | *Date* | 2007/4/12 | | *File* | script/kids/3DMapSystemUI/EBook/EBook_db.lua | ---+++ Description %T% __Sample Code__ <verbatim> NPL.load("(gl)script/kids/3DMapSystemUI/EBook/EBook_db.lua"); -- EBook_db.book contains the current book EBook_db.NewBook(filename); EBook_db.NewPage(page); EBook_db.LoadEBookFromFile(filename); EBook_db.SaveCurrentEBook(); </verbatim> ---+++ Member Functions ---++++ !EBook_db.GetCurrentBook <verbatim> EBook_db: if(not EBook_db) then EBook_db={}; end EBook_db.webservice_UploadUserFile = L("UploadUserFile.asmx"); EBook_db.webservice_SubmitEBook = L("SubmitEBook.asmx"); EBook_db.webservice_UploadUserFile = "http://localhost:1225/KidsMovieSite/UploadUserFile.asmx"; EBook_db.webservice_SubmitEBook = "http://localhost:1225/KidsMovieSite/SubmitEBook.asmx"; EBook_db.DefaultCategoryID = 110; -- default ebook category id on the community website. EBook_db.IsUploadFinished = true; EBook_db.articleURL = ""; EBook_db.msg = nil; -- upload message in progress EBook_db.callbackScript=nil; EBook_db.library_path = "EBooks/"; EBook_db.MaxBookPages = 200; an entire book can be inside a zip file, e.g. "EBooks/MyBook" can be zipped to "EBooks/MyBook.zip" please note that files in the zip book file must be relative path like "MyBook/*.*" in the above case. EBook_db.LastZipBookFile = nil; the current book EBook_db.book = nil; the empty book template. EBook_db.empty_book = { book_path = nil, -- such as "EBooks/MyBook/" book_file = nil, -- such as "EBooks/MyBook/MyBook.book.lua" media_path = nil, -- such as "EBooks/MyBook/media/" worlds_path = nil, -- such as "EBooks/MyBook/worlds/" author = "LiXizhi", createtime = "2007-4-12", bookname = L"an empty book", style = L"standard", -- book style, such as layout, etc abstract = nil, -- abstract of the book, usually less than 50 words. readonly = false, -- whether read only currentpage = 1, -- index of the current page pagesCount = 0; UnusedPageID = 1; -- the next unused page ID, increased by one for each new page created. -- the actual page is in array at [1], [2], etc. template pages are in key, value pairs. pages = { PageTempate_empty = { pageid = 1, -- usually same as the page index, unless we support insert pages in future. pagetitle = "untitled", pagetext = "enter your text here", pagestyle = "empty", -- appearance of the page mediafile = nil, -- the media file associated with the page mediascale = 1, -- the world file path associated with the page, usually book.worlds_path.."w"..pageid -- sometimes, it can also be an URL beginning with http worldpath = nil, autosave_world = false, -- whether the world info such as player position associated with the page is automatically saved. PlayerName = nil, PlayerPos = nil, -- such as {100,0 200} PlayerModel = nil, -- main player model file ClipFile = nil, -- the clip file in the world to play. voice_file = nil, -- the voice file path, usually book.media_path..pageid.."_voice.wav" music_file = nil, -- the music file path, usually } }, -- this table is not serialized. edit_att = { is_modified = false, } }</verbatim>; __syntax__ <verbatim>function EBook_db.GetCurrentBook()</verbatim> ---++++ !EBook_db.SetBookPath * _param_ __bookpath__ : such as EBooks/MyBook * _param_ __book__ : which book to set. __syntax__ <verbatim>function EBook_db.SetBookPath(bookpath, book)</verbatim> __parameters__ | *bookpath* | such as EBooks/MyBook | | *book* | | ---++++ !EBook_db.NewPage create a new page at the end f the book. * _param_ __page__ : this can be nil, a partial page, etc. * _param_ __nInsertAfter__ : the page index after which the new page is added. it can be nil, which means the end of page. * _return_ ____ : return true or an error message. __syntax__ <verbatim>function EBook_db.NewPage(page, nInsertAfter)</verbatim> __parameters__ | *page* | this can be nil, a partial page, etc. | | *nInsertAfter* | | | *return* | return true or an error message. | ---++++ !EBook_db.InsertPage insert a page * _param_ __page__ : page to be added * _param_ __nInsertAfter__ : the page index after which the new page is added. it can be nil, which means the end of page. __syntax__ <verbatim>function EBook_db.InsertPage(page, nInsertAfter)</verbatim> __parameters__ | *page* | page to be added | | *nInsertAfter* | | ---++++ !EBook_db.RemovePage remove a page at a given index return true if succeed, or nil if can not remove the only left page __syntax__ <verbatim>function EBook_db.RemovePage(nPageIndex)</verbatim> __parameters__ | *nPageIndex* | | ---++++ !EBook_db.NewBook create a new book by name at default library_path. One needs to fill the author info etc, in the current book at a later time. And Call the SaveCurrentEBook() function to write the new book to file. error message is returned in the false parameter. or true if succeed. __syntax__ <verbatim>function EBook_db.NewBook(bookName)</verbatim> __parameters__ | *bookName* | | ---++++ !EBook_db.LoadEBookByName * _param_ __bookname__ : this is just the book directory name or the zip file name. like "MyBook". * _param_ __true__ : or error message __syntax__ <verbatim>function EBook_db.LoadEBookByName(bookname)</verbatim> __parameters__ | *bookname* | this is just the book directory name or the zip file name. like "MyBook". | ---++++ !EBook_db.LoadEBookFromFile * _param_ __filename__ : load EBook by book file, such as "EBooks/MyBook/MyBook.book.lua" __syntax__ <verbatim>function EBook_db.LoadEBookFromFile(filename)</verbatim> __parameters__ | *filename* | load EBook by book file, such as "EBooks/MyBook/MyBook.book.lua" | ---++++ !EBook_db.SaveCurrentEBook [[ save current ebook to file EBook_db.SaveAssetToFile("temp/ebook_temp.lua"); ]] __syntax__ <verbatim>function EBook_db.SaveCurrentEBook()</verbatim> ---++++ !EBook_db.GetCurrentPage return the current page or nil. __syntax__ <verbatim>function EBook_db.GetCurrentPage()</verbatim> ---++++ !EBook_db.GotoPage return true or nil __syntax__ <verbatim>function EBook_db.GotoPage(nPageNumber)</verbatim> __parameters__ | *nPageNumber* | | ---++++ !EBook_db.AutoSavePageWorld save everything (world name, player position, movie clips, etc) in the current 3d world to the associated world info of the current page. __syntax__ <verbatim>function EBook_db.AutoSavePageWorld()</verbatim> ---++++ !EBook_db.GetPageScreenShotPath get the screen shot file path of this page __syntax__ <verbatim>function EBook_db.GetPageScreenShotPath()</verbatim> ---++++ !EBook_db.SavePageWorld just save the page world, even if autosave is not enabled. however, if the book is read-only, it is not saved. __syntax__ <verbatim>function EBook_db.SavePageWorld()</verbatim> ---++++ !EBook_db.SubmitEBook submit the current EBook via webservice TODO: we should move the many UI related _guihelper.MessageBox(), etc to EBook_MainMenu.OnClickPublish_UploadToWeb. for simplicity, I just mixed UI and BLLogic in EBook_db class. __syntax__ <verbatim>function EBook_db.SubmitEBook()</verbatim> ---++++ !EBook_db.SaveAsZipFile save the entire book as the zip file __syntax__ <verbatim>function EBook_db.SaveAsZipFile()</verbatim> ---++++ !EBook_db.SaveZipFile save and overwrite without asking any question __syntax__ <verbatim>function EBook_db.SaveZipFile(zipfile)</verbatim> __parameters__ | *zipfile* | | ---++ Main Menu for ebook | *Title* | Main Menu for ebook | | *Author(s)* | LiXizhi | | *Date* | 2007/4/12 | | *File* | script/kids/3DMapSystemUI/EBook/EBook_MainMenu.lua | ---+++ Description %T% __Sample Code__ <verbatim> NPL.load("(gl)script/kids/3DMapSystemUI/EBook/EBook_MainMenu.lua"); EBook_MainMenu.Show(); </verbatim> ---+++ Member Functions ---++++ !EBook_MainMenu.Show properties EBook_MainMenu.NeedsRefresh = true; appearance EBook_MainMenu.main_bg = "Texture/kidui/explorer/bg.png" EBook_MainMenu.pagetab_bg = "Texture/kidui/explorer/pagetab.png" EBook_MainMenu.pagetab_selected_bg = "Texture/kidui/explorer/pagetab_selected.png" EBook_MainMenu.panel_bg = "Texture/kidui/explorer/panel_bg.png" EBook_MainMenu.panel_sub_bg = "Texture/kidui/explorer/panel_sub_bg.png" EBook_MainMenu.button_bg = "Texture/kidui/explorer/button.png" EBook_MainMenu.listbox_bg = "Texture/kidui/explorer/listbox_bg.png" EBook_MainMenu.dropdownarrow_bg = "Texture/kidui/explorer/dropdown_arrow.png" EBook_MainMenu.dropdownlist_cont_bg = "Texture/kidui/explorer/editbox256x32.png" EBook_MainMenu.editbox_bg = "Texture/kidui/explorer/editbox128x32.png" EBook_MainMenu.editbox_long_bg = "Texture/kidui/explorer/editbox256x32.png" tab pages EBook_MainMenu.tabpages = {"EB_MenuPage_MyBooks", "EB_MenuPage_NewBook", "EB_MenuPage_Download", "EB_MenuPage_Publish",}; EBook_MainMenu.tabbuttons = {"EB_MenuPage_MyBooks_TabBtn", "EB_MenuPage_NewBook_TabBtn", "EB_MenuPage_Download_TabBtn", "EB_MenuPage_Publish_TabBtn", }; * _param_ __bShow__ : boolean to show or hide. if nil, it will toggle current setting. __syntax__ <verbatim>function EBook_MainMenu.Show(bShow, left, top)</verbatim> __parameters__ | *bShow* | boolean to show or hide. if nil, it will toggle current setting. | | *left* | | | *top* | | ---++++ !EBook_MainMenu.OnDestory destory the control __syntax__ <verbatim>function EBook_MainMenu.OnDestory()</verbatim> ---++++ !EBook_MainMenu.OnClose just hide the window __syntax__ <verbatim>function EBook_MainMenu.OnClose()</verbatim> ---++++ !EBook_MainMenu.SwitchMainTabs * _param_ __nIndex__ : 1-4 __syntax__ <verbatim>function EBook_MainMenu.SwitchMainTabs(nIndex)</verbatim> __parameters__ | *nIndex* | 1-4 | ---++++ !EBook_MainMenu.OnNewBook_Create_btn ----------------------------------- new book page ----------------------------------- __syntax__ <verbatim>function EBook_MainMenu.OnNewBook_Create_btn()</verbatim> ---++++ !EBook_MainMenu.OnClickMyBooks_OpenBook ----------------------------------- load book page ----------------------------------- __syntax__ <verbatim>function EBook_MainMenu.OnClickMyBooks_OpenBook()</verbatim> ---++++ !EBook_MainMenu.OnClickMyBooks_DeleteBook_imp * _param_ __worldpath__ : which world to delete __syntax__ <verbatim>function EBook_MainMenu.OnClickMyBooks_DeleteBook_imp(worldpath)</verbatim> __parameters__ | *worldpath* | which world to delete | ---++++ !EBook_MainMenu.OnClickSave_btn ----------------------------------- save page ----------------------------------- __syntax__ <verbatim>function EBook_MainMenu.OnClickSave_btn()</verbatim> ---++++ !EBook_MainMenu.OnClickPublish_UploadToWeb ----------------------------------- Publish page ----------------------------------- __syntax__ <verbatim>function EBook_MainMenu.OnClickPublish_UploadToWeb()</verbatim> ---++ template: windows form or modeless dialog | *Title* | template: windows form or modeless dialog | | *Author(s)* | [your name], original template by LiXizhi | | *Date* | 2007/2/7 | | *File* | script/kids/3DMapSystemUI/EBook/EBook_MediaMenu.lua | ---+++ Description %T% __Sample Code__ <verbatim> NPL.load("(gl)script/kids/3DMapSystemUI/EBook/EBook_MediaMenu.lua"); EBook_MediaMenu.Show(); </verbatim> ---+++ Member Functions ---++++ !EBook_MediaMenu.SwitchFilesTabs common control library NPL.load("(gl)script/kids/3DMapSystemUI/EBook/EBook.lua"); NPL.load("(gl)script/kids/3DMapSystemUI/EBook/EBook_db.lua"); NPL.load("(gl)script/ide/common_control.lua"); NPL.load("(gl)script/ide/FileDialog.lua"); local L = CommonCtrl.Locale("ParaWorld"); if(not EBook_MediaMenu) then EBook_MediaMenu={}; end properties EBook_MediaMenu.NeedsRefresh = true; appearance EBook_MediaMenu.main_bg = "Texture/kidui/explorer/bg.png" EBook_MediaMenu.pagetab_bg = "Texture/kidui/explorer/pagetab.png" EBook_MediaMenu.pagetab_selected_bg = "Texture/kidui/explorer/pagetab_selected.png" EBook_MediaMenu.panel_bg = "Texture/kidui/explorer/panel_bg.png" EBook_MediaMenu.panel_sub_bg = "Texture/kidui/explorer/panel_sub_bg.png" EBook_MediaMenu.button_bg = "Texture/kidui/explorer/button.png" EBook_MediaMenu.listbox_bg = "Texture/kidui/explorer/listbox_bg.png" EBook_MediaMenu.dropdownarrow_bg = "Texture/kidui/explorer/dropdown_arrow.png" EBook_MediaMenu.dropdownlist_cont_bg = "Texture/kidui/explorer/editbox256x32.png" EBook_MediaMenu.editbox_bg = "Texture/kidui/explorer/editbox128x32.png" EBook_MediaMenu.editbox_long_bg = "Texture/kidui/explorer/editbox256x32.png" tab pages EBook_MediaMenu.tabpages = {"EB_MMenuPage_3DWorld", "EB_MMenuPage_Files", "EB_MMenuPage_Network", "EB_MMenuPage_Audio", }; EBook_MediaMenu.tabbuttons = {"EB_MMenuPage_3DWorld_TabBtn", "EB_MMenuPage_Files_TabBtn", "EB_MMenuPage_Network_TabBtn", "EB_MMenuPage_Audio_TabBtn", }; EBook_MediaMenu.worldtabpages = {"EB_MMenu_LoadWorld", "EB_MMenu_NewWorld", "EB_MMenu_NewWorldCreated", }; EBook_MediaMenu.worldtabbuttons = {"EB_MMenu_LoadWorld_TabBtn", "EB_MMenu_NewWorld_TabBtn", }; EBook_MediaMenu.filestabbuttons = {"EB_MMenu_Files_ScreenshotTabBtn", "EB_MMenu_Files_MovieTabBtn", "EB_MMenu_Files_OthersTabBtn", }; * _param_ __nIndex__ : __syntax__ <verbatim>function EBook_MediaMenu.SwitchFilesTabs(nIndex)</verbatim> __parameters__ | *nIndex* | | ---++++ !EBook_MediaMenu.SwitchMainTabs * _param_ __nIndex__ : 1-4 __syntax__ <verbatim>function EBook_MediaMenu.SwitchMainTabs(nIndex)</verbatim> __parameters__ | *nIndex* | 1-4 | ---++++ !EBook_MediaMenu.SwitchWorldTabs * _param_ __nIndex__ : 1-3 __syntax__ <verbatim>function EBook_MediaMenu.SwitchWorldTabs(nIndex)</verbatim> __parameters__ | *nIndex* | 1-3 | ---++++ !EBook_MediaMenu.ShowRecorder show a top level recorder window __syntax__ <verbatim>function EBook_MediaMenu.ShowRecorder(bShow, left, top)</verbatim> __parameters__ | *bShow* | | | *left* | | | *top* | | ---++++ !EBook_MediaMenu.OnDestory destory the control __syntax__ <verbatim>function EBook_MediaMenu.OnDestory()</verbatim> ---++++ !EBook_MediaMenu.OnClose just hide the window __syntax__ <verbatim>function EBook_MediaMenu.OnClose()</verbatim> ---++++ !EBook_MediaMenu.OnSelectLoadWorld_WorldList ------------------------------------ world page ------------------------------------ __syntax__ <verbatim>function EBook_MediaMenu.OnSelectLoadWorld_WorldList()</verbatim> ---++++ !EBook_MediaMenu.OnClickDrawing ------------------------------------- drawing page ------------------------------------- __syntax__ <verbatim>function EBook_MediaMenu.OnClickDrawing()</verbatim> ---++++ !EBook_MediaMenu.OnClickSaveDrawing save drawing __syntax__ <verbatim>function EBook_MediaMenu.OnClickSaveDrawing()</verbatim> ---++++ !EBook_MediaMenu.OnSelectFiles_FileList ------------------------------------- files page ------------------------------------- called when the selection changed __syntax__ <verbatim>function EBook_MediaMenu.OnSelectFiles_FileList()</verbatim> ---++++ !EBook_MediaMenu.OnClickFiles_ClearBtn called to clear the text __syntax__ <verbatim>function EBook_MediaMenu.OnClickFiles_ClearBtn()</verbatim> ---++++ !EBook_MediaMenu.OnClickFiles_OKbtn called to submit the file __syntax__ <verbatim>function EBook_MediaMenu.OnClickFiles_OKbtn()</verbatim> ---++++ !EBook_MediaMenu.OnClickAudio_stop ------------------------------------ audio page ------------------------------------ __syntax__ <verbatim>function EBook_MediaMenu.OnClickAudio_stop()</verbatim> ---++ template: windows form or modeless dialog | *Title* | template: windows form or modeless dialog | | *Author(s)* | SunLingfeng | | *Date* | 2007/4/24 | | *File* | script/kids/3DMapSystemUI/EBook/ImageViewer.lua | ---+++ Description %T% __Sample Code__ <verbatim> NPL.load("(gl)script/kids/3DMapSystemUI/EBook/ImageViewer.lua"); local ctl = CommonCtrl.ImageViewer:new{ name = "ImageViewer1", alignment = "_lt", left=0, top=0, width = 512, height = 400, parent = _parent, imagefile = nil; }; ctl:Show(); call CommonCtrl.ImageViewer.Scale(sCtrlName, deltaScale) to scale the texture size, deltaScale = 0,no scale; deltaScale = positive number, zoom in; deltaScale = negative number,zoom out call CommonCtrl.ImageViewer.MoveImg(sCtrlName, deltaX, deltaY) to move the view region when the texture size is bigger than then window size. deltaX,deltaY is the offset alone x and y axis. use CommonCtrl.ImageViewer.inverse_mouse to inverse the navigation direction. </verbatim> ---+++ Member Functions ---++++ !ImageViewer:new <verbatim> common control library NPL.load("(gl)script/ide/common_control.lua"); define a new control in the common control libary default member attributes local ImageViewer = { -- the top level control name name = "ImageViewer1", -- normal window size alignment = "_lt", left = 0, top = 0, width = 400, height = 400, parent = nil, -- data imagefile = nil, texture = nil, minScale = 1, maxScale = 4, scaleDelta = 0.1, totalScale = 1, inverse_mouse = false, tex2WndScale = {x=0,y=0}, texSize = {x=0,y = 0}, refTexSize = {x=0,y = 0}, texPos_lt = {x = 0,y = 0}, maxTexPos_lt = {x = 0, y = 0}, isMouseDown = false, lastMousePos = {x = 0,y=0}, aspect; }</verbatim> CommonCtrl.ImageViewer = ImageViewer; constructor __syntax__ <verbatim>function ImageViewer:new (o)</verbatim> __parameters__ | *o* | | ---++++ !ImageViewer:Destroy Destroy the UI control __syntax__ <verbatim>function ImageViewer:Destroy ()</verbatim> ---++++ !ImageViewer:Show * _param_ __bShow__ : boolean to show or hide. if nil, it will toggle current setting. __syntax__ <verbatim>function ImageViewer:Show(bShow)</verbatim> __parameters__ | *bShow* | boolean to show or hide. if nil, it will toggle current setting. | ---++++ !ImageViewer:SetImage call this function to set the image __syntax__ <verbatim>function ImageViewer:SetImage(imagefile)</verbatim> __parameters__ | *imagefile* | | ---++++ !ImageViewer.OnClose close the given control __syntax__ <verbatim>function ImageViewer.OnClose(sCtrlName)</verbatim> __parameters__ | *sCtrlName* | | ---++ Popup editor | *Title* | Popup editor | | *Author(s)* | LiXizhi | | *Date* | 2007/4/16 | | *File* | script/kids/3DMapSystemUI/EBook/PopupEditor.lua | ---+++ Description %T% __Sample Code__ <verbatim> NPL.load("(gl)script/kids/3DMapSystemUI/EBook/PopupEditor.lua"); local ctl = CommonCtrl.PopupEditor:new{ name = "PopupEditor1", alignment = "_lt", left=0, top=0, width = 400, textwidth = 360, height = 300, item_count = 3, item_height = 26, item_spacing = 2, parent = nil, }; ctl:Show(true, "hello\nall!"); </verbatim> ---+++ Member Functions ---++++ !PopupEditor:new <verbatim> common control library NPL.load("(gl)script/ide/common_control.lua"); local L = CommonCtrl.Locale("ParaWorld"); define a new control in the common control libary default member attributes local PopupEditor = { -- the top level control name name = "PopupEditor1", -- normal window size alignment = "_lt", left = 0, top = 0, width = 400, height = 400, textwidth = nil, item_count = 3, item_height = 26, item_spacing = 2, parent = nil, -- appearance main_bg = nil, editbox_bg = "", -- OnOK event, it can be nil, a string to be executed or a function of type void ()(Ctrl, text) -- it will be called when the user pressed the OK button. on_ok= nil, }</verbatim> CommonCtrl.PopupEditor = PopupEditor; constructor __syntax__ <verbatim>function PopupEditor:new (o)</verbatim> __parameters__ | *o* | | ---++++ !PopupEditor:Destroy Destroy the UI control __syntax__ <verbatim>function PopupEditor:Destroy ()</verbatim> ---++++ !PopupEditor:Show * _param_ __bShow__ : boolean to show or hide. if nil, it will toggle current setting. * _param_ __text__ : text to be displayed. this can be nil. __syntax__ <verbatim>function PopupEditor:Show(bShow, text, left, top)</verbatim> __parameters__ | *bShow* | boolean to show or hide. if nil, it will toggle current setting. | | *text* | | | *left* | | | *top* | | ---++++ !PopupEditor.OnClose close the given control __syntax__ <verbatim>function PopupEditor.OnClose(sCtrlName)</verbatim> __parameters__ | *sCtrlName* | | ---++++ !CommonCtrl.PopupEditor.OnHideMe call to hide __syntax__ <verbatim>function CommonCtrl.PopupEditor.OnHideMe(sCtrlName)</verbatim> __parameters__ | *sCtrlName* | | ---++++ !CommonCtrl.PopupEditor.OnText called when the text changes __syntax__ <verbatim>function CommonCtrl.PopupEditor.OnText(sCtrlName, nLineIndex)</verbatim> __parameters__ | *sCtrlName* | | | *nLineIndex* | | ---++++ !CommonCtrl.PopupEditor:ProcessLine update the given line; if necessary, it will also update subsequent lines recursively. * _param_ __nLineIndex__ : line index * _param_ __command__ : 0: update the line. If param1 is nil, it will not change the focus, otherwise change the focus if necessary. 1: prepend text(param1) to the given line 4: append text(param1) to the given line 2: insert return key at the current caret position.If param1 is nil, it will not change the focus, otherwise change the focus if necessary. 3: insert a new line of text(param1) at the current line 5: delete a given line __syntax__ <verbatim>function CommonCtrl.PopupEditor:ProcessLine(nLineIndex, command, param1)</verbatim> __parameters__ | *nLineIndex* | line index | | *command* | | | *param1* | | ---++++ !CommonCtrl.PopupEditor:SetText set the text __syntax__ <verbatim>function CommonCtrl.PopupEditor:SetText(text)</verbatim> __parameters__ | *text* | | ---++++ !CommonCtrl.PopupEditor:GetText return the concartenated text __syntax__ <verbatim>function CommonCtrl.PopupEditor:GetText()</verbatim> ---++++ !CommonCtrl.PopupEditor.OnOK close the given control __syntax__ <verbatim>function CommonCtrl.PopupEditor.OnOK(sCtrlName)</verbatim> __parameters__ | *sCtrlName* | | %STOPINCLUDE%
E
dit
|
A
ttach
|
P
rint version
|
H
istory
: r1
|
B
acklinks
|
V
iew topic
|
Ra
w
edit
|
M
ore topic actions
Topic revision: r1 - 2008-02-29
-
LiXizhi
Home
Site map
CCWeb web
HaqiTeen web
Main web
ParaEngine web
TWiki web
Main Web
Users
Groups
Index
Search
Changes
Notifications
RSS Feed
Statistics
导航页WebTopMenu
Preferences
开发指南
Getting Started
ParacraftSDK
NPL
MCML
NPL Reference Manual
美术Mod
Account
Log In
English
简体中文
簡體中文
E
dit
A
ttach
Copyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback