|
Nerd
Join Date: Sep 2011
Location: Berlin
Posts: 3,825
|
|
I don't see why this is needed though, couldn't you just browse folder's in RC or Graal/levels/images instead?
|
You'd have to download them if you were browsing them in rc and not all the images uploaded to the server are downloaded to the client. Not until you've seen them that is. Using this eliminates both of those issues.
and callimuc y u be nast 2 emmy D:
That's styled code. I admit, the indentations are a little over the top, but I coded it in notepad ++
Here you go
PHP Code:
function onCreated() { this.allowedFiles = { ".png", ".gif", ".jpeg", ".mng", ".apng", ".bmp" }; }
function onActionServerside(option) { switch (option) { case "getFolderContents": { temp.folderContent.loadFolder("levels/" @ params[1] @ "/*", false); for (imageList: temp.folderContent) { temp.rawFile = extractfilebase(imageList); temp.imageExtension = imageList.substring(temp.rawFile.length()); if (temp.imageExtension in this.allowedFiles) { temp.contentList.add(imageList); } } waitfor(temp.contentList.add, "", 1); triggerclient("gui", name, "getFolderContents", temp.contentList, params[1]); break; } } case "setCharacterFeature": { switch (params[1]) { case "body": { player.body = params[2]; break; } case "head": { player.head = params[2]; break; } break; } } }
//#CLIENTSIDE
const VERSION = "2.3.2";
function onCreated() { DrawGUI(); }
function DrawGUI() {
// Image Viewer Window Main new GuiWindowCtrl("Image_Viewer_Window") { profile = "GuiBlueWindowProfile"; width = 700; height = 430; clientrelative = true; clientextent = { width, height }; x = screenwidth / 2 - width / 2; y = screenheight / 2 - height / 2; canresize = canmaximize = visible = false; isexternal = true; text = "GUI Image Viewer [Version:" SPC VERSION @ "] By: Emera";
new GuiScrollCtrl("Image_Viewer_Window_Scroll") { profile = "GuiBlueScrollProfile"; width = 180; height = 390; x = y = 5; hScrollBar = vScrollBar = "dynamic";
new GuiTreeViewCtrl("Image_Viewer_List") { profile = "GuiBlueTreeViewProfile"; width = 170; fitparentwidth = true; x = y = 0; sort(); sortmode = 1; } }
new GuiScrollCtrl("Image_Viewer_Picture_Scroll") { profile = "GuiBlueScrollProfile"; width = 500; height = 390; x = 190; y = 5; hScrollBar = vScrollBar = "dynamic"; new GuiShowImgCtrl("Image_Viewer_Picture") { x = y = 0; } }
new GuiTextEditCtrl("Image_Viewer_Search") { profile = "GuiBlueTextEditProfile"; width = 150; height = 25; x = 5; y = 400; }
new GuiButtonCtrl("Image_Viewer_Button1") { profile = "GuiBlueButtonProfile"; width = 75; height = 25; x = 160; y = 400; text = "Apply"; hint = "Apply the select image to your character. (Head, body and hat only)"; }
new GuiButtonCtrl("Image_Viewer_Button2") { profile = "GuiBlueButtonProfile"; width = 75; height = 25; x = 160 + width + 5; y = 400; text = "Help"; hint = "Open the help menu if you're stuck!"; }
new GuiTextCtrl("Image_Viewer_StatusText") { profile = GuiBlueTextProfile; width = 250; x = 320; y = 402; text = ""; } }
// Help Window
new GuiWindowCtrl("Image_Help_Window") { profile = "GuiBlueWindowProfile"; width = 250; height = 260; clientrelative = true; clientextent = { width, height }; x = screenwidth / 2 - width / 2; y = screenheight / 2 - height / 2; canresize = canmaximize = canminimize = canmoze = visible = false; bringtofront(); isexternal = true; text = "Help Page";
new GuiMLTextCtrl("Image_Help_Text") { profile = "GuiBlueMLTextProfile"; width = 240; x = y = 5; active = false; text = "To open a folder, type the folder name into the bottom left search bar. If the image contains a file with an image extension (for example, .PNG), then those files will be listed. If an image doesn't load the first time you click it, that means the image hasn't been downloaded before. Simply click that file again and it will load. When downloading a file, if the image fails to show and you are notified in the bottom right of the window with a download file message, this means that the image hasn't been downlaoded yet. Simple click the entry again to show the image!"; } }
// Error Window
new GuiWindowCtrl("Image_Error_Window") { profile = "GuiBlueWindowProfile"; width = 250; height = 90; clientrelative = true; clientextent = { width, height }; x = screenwidth / 2 - width / 2; y = screenheight / 2 - height / 2; isexternal = true; canresize = canclose = canminimize = canmaximize = visible = canmove = false; text = "Error";
new GuiButtonCtrl("Image_Error_Button1") { profile = "GuiBlueButtonProfile"; width = 100; height = 25; x = Image_Error_Window.width / 2 - width / 2 - 5; y = 60; text = "Close"; }
new GuiMLTextCtrl("Image_Error_Text") { profile = "GuiBlueMLTextProfile"; width = 240; x = y = 5; text = "<center><b>This folder does not exist, or does not contain any image files. Please try and list another folder.</b>"; } } }
// GUI ACTIONS
function Image_Viewer_Search.onAction() { if (Image_Viewer_Search.text.starts("levels/") || Image_Viewer_Search.text == NULL) { return; } else { this.imagePath = Image_Viewer_Search.text; Image_Viewer_StatusText.text = "Loading folder" SPC Image_Viewer_Search.text; FetchImageList(this.imagePath); } Image_Viewer_Search.text = ""; }
function Image_Viewer_Button1.onAction() { switch (this.imagePath) { temp.image = Image_Viewer_List.getSelectedNode(); case "hats": { setPlayerAtt("hat", temp.image); break; } case "bodies": { setPlayerAtt("body", temp.image); break; } case "heads": { setPlayerAtt("head", temp.image); break; } } }
function Image_Viewer_List.onSelect() { temp.imageName = Image_Viewer_List.getSelectedNode(); temp.imageWidth = getImgWidth(temp.imageName); temp.imageHeight = getImgHeight(temp.imageName);
if (isDownloading(temp.imageName)) { Image_Viewer_StatusText.text = "Downloading" SPC temp.imageName; } ShowFile(temp.imageName, temp.imageWidth, temp.imageHeight); }
function Image_Viewer_Button2.onAction() { Image_Help_Window.visible = !Image_Help_Window.visible;
if (Image_Help_Window.visible) { Image_Help_Window.bringtofront(); } }
function Image_Error_Button1.onAction() { Image_Error_Window.visible = false; Image_Viewer_Window.active = true; }
// SYSTEM FUNCTIONS
function ShowFile(imageName, imageWidth, imageHeight) { with(Image_Viewer_Picture) { width = imageWidth; height = imageHeight; image = imageName; } }
function setPlayerAtt(feature, imageName) { switch (feature) { case "hat": { player.attr[1] = imageName; break; } case "head": { triggerserver("gui", name, "setCharacterFeature", "head", imageName); break; } case "body": { triggerserver("gui", name, "setCharacterFeature", "body", imageName); break; } } }
function onKeyPressed(code, Key) { if (Key == "V") { Image_Viewer_Window.visible = !Image_Viewer_Window.visible; } }
function FetchImageList(folderName) { Image_Viewer_List.clearnodes(); triggerserver("gui", name, "getFolderContents", folderName); }
function onActionClientside(option) { switch (option) { case "getFolderContents": { for (contentList: params[1]) { Image_Viewer_List.addnode(contentList); } if (Image_Viewer_List.nodes.size() == NULL) { with(Image_Error_Window) { visible = true; makefirstresponder(true); bringtofront(); } Image_Viewer_Window.active = false; } with(Image_Viewer_List) { makeFirstResponder(true); sort(); } } } }
|