EBookAppDev
description: 娴忚銆侀槄璇汇€佸埗浣?D鐢靛瓙涔︺€?D鐢靛瓙涔︾敱鐜╁鍒涗綔鐨勬枃瀛楋紝鍥剧墖锛屽0闊筹紝3D涓栫晫缁勬垚銆?鐢ㄦ埛鍙互鐢ㄥ畠鍒朵綔App甯姪鍜岃鏄庝功锛岃春鍗★紝鐩稿唽绛夌瓑锛屽彂甯冨悗鍙互鍜屾湅鍙嬪叡浜€
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
Map3DSystem.App.Commands.Call("File.EBook");
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);
Sample Code
NPL.load("(gl)script/kids/3DMapSystemUI/EBook/app_main.lua");
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 ConnectMode.
syntax
function MyCompany.Apps.EBook.OnConnection(app, connectMode)
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
function MyCompany.Apps.EBook.OnDisconnection(app, disconnectMode)
parameters
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 CommandStatusWanted
- return __ : returns according to statusWanted. it may return an integer by adding values in CommandStatus.
syntax
function MyCompany.Apps.EBook.OnQueryStatus(app, commandName, statusWanted)
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 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
function MyCompany.Apps.EBook.OnExec(app, commandName, params)
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
function MyCompany.Apps.EBook.OnRenderBox(mcmlData)
parameters
MyCompany.Apps.EBook.Navigate
called when the user wants to nagivate to the 3D world location relavent to this application
syntax
function MyCompany.Apps.EBook.Navigate()
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
function MyCompany.Apps.EBook.GotoHomepage()
MyCompany.Apps.EBook.DoQuickAction
called when user clicks the quick action for this application.
syntax
function MyCompany.Apps.EBook.DoQuickAction()
MyCompany.Apps.EBook.OnActivateDesktop
Add terrain, sky and ocean button to the toolbar.
syntax
function MyCompany.Apps.EBook.OnActivateDesktop(app)
parameters
MyCompany.Apps.EBook.OnDeactivateDesktop
syntax
function MyCompany.Apps.EBook.OnDeactivateDesktop()
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
function MyCompany.Apps.EBook.MSGProc(window, msg)
parameters
EBook main window
Title |
EBook main window |
Author(s) |
LiXizhi |
Date |
2007/4/12 |
File |
script/kids/3DMapSystemUI/EBook/EBook.lua |
Description
Sample Code
NPL.load("(gl)script/kids/3DMapSystemUI/EBook/EBook.lua");
EBook.Show;
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
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.
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
function EBook.Show(bShow, _parent, parentWindow)
parameters
bShow |
show or hide the panel |
parent |
|
parentWindow |
|
EBook.OnDestory
destory the control
syntax
function EBook.OnDestory()
EBook.OnClickMainMenu
click to show the mainmenu
syntax
function EBook.OnClickMainMenu()
EBook.OnClickMediaMenu
click to show the media menu
syntax
function EBook.OnClickMediaMenu()
EBook.OnClickNewPage_Btn
create a new page just after the current page.
syntax
function EBook.OnClickNewPage_Btn()
EBook.OnClickRemovePage_Btn
remove the current page.
syntax
function EBook.OnClickRemovePage_Btn()
EBook.OnClickEditPageTitle
call this to edit the page text
syntax
function EBook.OnClickEditPageTitle()
EBook.OnClickEditPageText
call this to edit the page text
syntax
function EBook.OnClickEditPageText()
EBook.OnGotoPage
- param pageNumber : error message is displayed if invalid page number.
syntax
function EBook.OnGotoPage(pageNumber)
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
function EBook.OnClickOpenBook(nIndex)
parameters
nIndex |
book icon index, normally 1-4 |
EBook.OnTreeViewOpenBook
open book
syntax
function EBook.OnTreeViewOpenBook(treeNode)
parameters
EBook.OpenBook
update method
call this function to open a certain book by name.
syntax
function EBook.OpenBook(bookname)
parameters
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
function EBook.UpdateBookShelf(refreshBookList)
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
function EBook.UpdatePage()
EBook.UpdatePageMedia
call this if the page media is changed.
syntax
function EBook.UpdatePageMedia()
EBook.UpdatePageText
call this if the current page text is changed.
syntax
function EBook.UpdatePageText()
EBook.PlayPageAudio
called to play the page music associated with the page.
syntax
function EBook.PlayPageAudio()
EBook.LockBook
make the book read-only or not.
- param bLock :, if nil it will be toggled.
syntax
function EBook.LockBook(bLock)
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
function EBook.ResetBookWorld(bShow)
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
function EBook.OnClickReturnToBookBtn()
EBook.OnClickEnterPageWorld
on click the page world
syntax
function EBook.OnClickEnterPageWorld()
EBook.OnClickHelp
open the help book
syntax
function EBook.OnClickHelp()
The EBook Database
Title |
The EBook Database |
Author(s) |
LiXizhi |
Date |
2007/4/12 |
File |
script/kids/3DMapSystemUI/EBook/EBook_db.lua |
Description
Sample Code
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();
Member Functions
EBook_db.GetCurrentBook
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,
}
}
;
syntax
function EBook_db.GetCurrentBook()
EBook_db.SetBookPath
- param bookpath : such as EBooks/MyBook
- param book : which book to set.
syntax
function EBook_db.SetBookPath(bookpath, book)
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
function EBook_db.NewPage(page, nInsertAfter)
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
function EBook_db.InsertPage(page, nInsertAfter)
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
function EBook_db.RemovePage(nPageIndex)
parameters
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
function EBook_db.NewBook(bookName)
parameters
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
function EBook_db.LoadEBookByName(bookname)
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
function EBook_db.LoadEBookFromFile(filename)
parameters
filename |
load EBook by book file, such as "EBooks/MyBook/MyBook.book.lua" |
EBook_db.SaveCurrentEBook
[[ save current ebook to file
SaveAssetToFile("temp/ebook_temp.lua");
]]
syntax
function EBook_db.SaveCurrentEBook()
EBook_db.GetCurrentPage
return the current page or nil.
syntax
function EBook_db.GetCurrentPage()
EBook_db.GotoPage
return true or nil
syntax
function EBook_db.GotoPage(nPageNumber)
parameters
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
function EBook_db.AutoSavePageWorld()
EBook_db.GetPageScreenShotPath
get the screen shot file path of this page
syntax
function EBook_db.GetPageScreenShotPath()
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
function EBook_db.SavePageWorld()
EBook_db.SubmitEBook
submit the current EBook via webservice
TODO: we should move the many UI related _guihelper.MessageBox(), etc to
OnClickPublish_UploadToWeb.
for simplicity, I just mixed UI and BLLogic in EBook_db class.
syntax
function EBook_db.SubmitEBook()
EBook_db.SaveAsZipFile
save the entire book as the zip file
syntax
function EBook_db.SaveAsZipFile()
EBook_db.SaveZipFile
save and overwrite without asking any question
syntax
function EBook_db.SaveZipFile(zipfile)
parameters
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
Sample Code
NPL.load("(gl)script/kids/3DMapSystemUI/EBook/EBook_MainMenu.lua");
EBook_MainMenu.Show();
Member Functions
EBook_MainMenu.Show
properties
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
function EBook_MainMenu.Show(bShow, left, top)
parameters
bShow |
boolean to show or hide. if nil, it will toggle current setting. |
left |
|
top |
|
EBook_MainMenu.OnDestory
destory the control
syntax
function EBook_MainMenu.OnDestory()
EBook_MainMenu.OnClose
just hide the window
syntax
function EBook_MainMenu.OnClose()
EBook_MainMenu.SwitchMainTabs
syntax
function EBook_MainMenu.SwitchMainTabs(nIndex)
parameters
EBook_MainMenu.OnNewBook_Create_btn
new book page
syntax
function EBook_MainMenu.OnNewBook_Create_btn()
EBook_MainMenu.OnClickMyBooks_OpenBook
load book page
syntax
function EBook_MainMenu.OnClickMyBooks_OpenBook()
EBook_MainMenu.OnClickMyBooks_DeleteBook_imp
- param worldpath : which world to delete
syntax
function EBook_MainMenu.OnClickMyBooks_DeleteBook_imp(worldpath)
parameters
worldpath |
which world to delete |
EBook_MainMenu.OnClickSave_btn
save page
syntax
function EBook_MainMenu.OnClickSave_btn()
EBook_MainMenu.OnClickPublish_UploadToWeb
Publish page
syntax
function EBook_MainMenu.OnClickPublish_UploadToWeb()
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
Sample Code
NPL.load("(gl)script/kids/3DMapSystemUI/EBook/EBook_MediaMenu.lua");
EBook_MediaMenu.Show();
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
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", };
syntax
function EBook_MediaMenu.SwitchFilesTabs(nIndex)
parameters
EBook_MediaMenu.SwitchMainTabs
syntax
function EBook_MediaMenu.SwitchMainTabs(nIndex)
parameters
EBook_MediaMenu.SwitchWorldTabs
syntax
function EBook_MediaMenu.SwitchWorldTabs(nIndex)
parameters
EBook_MediaMenu.ShowRecorder
show a top level recorder window
syntax
function EBook_MediaMenu.ShowRecorder(bShow, left, top)
parameters
EBook_MediaMenu.OnDestory
destory the control
syntax
function EBook_MediaMenu.OnDestory()
EBook_MediaMenu.OnClose
just hide the window
syntax
function EBook_MediaMenu.OnClose()
EBook_MediaMenu.OnSelectLoadWorld_WorldList
world page
syntax
function EBook_MediaMenu.OnSelectLoadWorld_WorldList()
EBook_MediaMenu.OnClickDrawing
drawing page
syntax
function EBook_MediaMenu.OnClickDrawing()
EBook_MediaMenu.OnClickSaveDrawing
save drawing
syntax
function EBook_MediaMenu.OnClickSaveDrawing()
EBook_MediaMenu.OnSelectFiles_FileList
files page
called when the selection changed
syntax
function EBook_MediaMenu.OnSelectFiles_FileList()
EBook_MediaMenu.OnClickFiles_ClearBtn
called to clear the text
syntax
function EBook_MediaMenu.OnClickFiles_ClearBtn()
EBook_MediaMenu.OnClickFiles_OKbtn
called to submit the file
syntax
function EBook_MediaMenu.OnClickFiles_OKbtn()
EBook_MediaMenu.OnClickAudio_stop
audio page
syntax
function EBook_MediaMenu.OnClickAudio_stop()
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
Sample Code
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.
Member Functions
ImageViewer:new
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;
}
ImageViewer =
ImageViewer;
constructor
syntax
function ImageViewer:new (o)
parameters
ImageViewer:Destroy
Destroy the UI control
syntax
function ImageViewer:Destroy ()
ImageViewer:Show
- param bShow : boolean to show or hide. if nil, it will toggle current setting.
syntax
function ImageViewer:Show(bShow)
parameters
bShow |
boolean to show or hide. if nil, it will toggle current setting. |
ImageViewer:SetImage
call this function to set the image
syntax
function ImageViewer:SetImage(imagefile)
parameters
ImageViewer.OnClose
close the given control
syntax
function ImageViewer.OnClose(sCtrlName)
parameters
Popup editor
Title |
Popup editor |
Author(s) |
LiXizhi |
Date |
2007/4/16 |
File |
script/kids/3DMapSystemUI/EBook/PopupEditor.lua |
Description
Sample Code
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!");
Member Functions
PopupEditor:new
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,
}
PopupEditor =
PopupEditor;
constructor
syntax
function PopupEditor:new (o)
parameters
PopupEditor:Destroy
Destroy the UI control
syntax
function PopupEditor:Destroy ()
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
function PopupEditor:Show(bShow, text, left, top)
parameters
bShow |
boolean to show or hide. if nil, it will toggle current setting. |
text |
|
left |
|
top |
|
PopupEditor.OnClose
close the given control
syntax
function PopupEditor.OnClose(sCtrlName)
parameters
CommonCtrl.PopupEditor.OnHideMe
call to hide
syntax
function CommonCtrl.PopupEditor.OnHideMe(sCtrlName)
parameters
CommonCtrl.PopupEditor.OnText
called when the text changes
syntax
function CommonCtrl.PopupEditor.OnText(sCtrlName, nLineIndex)
parameters
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
function CommonCtrl.PopupEditor:ProcessLine(nLineIndex, command, param1)
parameters
nLineIndex |
line index |
command |
|
param1 |
|
CommonCtrl.PopupEditor:SetText
set the text
syntax
function CommonCtrl.PopupEditor:SetText(text)
parameters
CommonCtrl.PopupEditor:GetText
return the concartenated text
syntax
function CommonCtrl.PopupEditor:GetText()
CommonCtrl.PopupEditor.OnOK
close the given control
syntax
function CommonCtrl.PopupEditor.OnOK(sCtrlName)
parameters