Graal Pastebin

New Paste
Pasted on March 19, 2012.
View the raw file

function onCreated() {
  this.allowedfiles = {
    ".png", ".gif", ".bmp", 
    ".jpeg", ".jpg",".apng", 
    ".mng"
  };
}
 
function onActionServerSide() {
  switch(params[0]) {
    case "getfolder":
    temp.folder.loadFolder("levels/" @ params[1] @ "/*",false);
      if (temp.folder == NULL) {
        triggerclient("gui",name,"error");
      } else {
        for (images : temp.folder) {
          temp.filebase = extractfilebase(images);
          temp.imagesuffix = images.substring(temp.filebase.length());
          if (imagesuffix in this.allowedfiles) {
            triggerclient("gui",name,"addfiles",images);
          }
        }
      }
    break;
    case "getheightandwidth":
      temp.imagewidth = getimgwidth(params[1]);
      temp.imageheight = getimgheight(params[1]);
      triggerclient("gui",name,"setwidthandheight",temp.imagewidth,temp.imageheight);
    break;
  }
}
 
//#CLIENTSIDE
 
function onCreated() {
  drawGUI();
}
 
function onPlayerChats() {
  if (player.chat == "/showimageviewer") {
    ImageViewerWindow.visible = true;
  } elseif (player.chat == "/hideimageviewer") {
    ImageViewerWindow.visible = false;
  }
}
 
function DrawGUI() {
  new GuiWindowCtrl("ImageViewerWindow") {
    profile = GuiBlueWindowProfile;
    width = 400;
    height = 225;
    x = screenwidth / 2 - width / 2;
    y = screenheight / 2 - height / 2;
    clientrelative = true;
    clientextent = {width,height};
    visible = true;
    canmaximize = canminimize = canresize = false;
    text = "Emera's Image Viewer";
 
    new GuiTextEditCtrl("ImageViewerSearchBar") {
      profile = GuiBlueTextEditProfile;
      width = 200;
      height = 25;
      x = 0;
      y = 200;
      active = true;
    }
 
    new GuiTextEditCtrl("ImageViewerImageBar") {
      profile = GuiBlueTextEditProfile;
      width = 200;
      height = 25;
      x = 200;
      y = 200;
      active = true;
    }
 
    new GuiControl("ImageViewerImageBorder") {
      useownprofile = true;
      width = 275;
      height = 200;
      x = 125;
      y = 0;
      profile.border = 1;
 
      new GuiScrollCtrl("ImageViewerImageScroll") {
        profile = GuiBlueScrollProfile;
        width = 275;
        height = 200;
        x = y = 0;
 
        new GuiShowImgCtrl("ImageViewerImage") {
          x = y = 0;
        }
      }
    }
 
    new GuiScrollCtrl("ImageViewerScroll") {
      profile = GuiBlueScrollProfile;
      width = 125;
      height = 200;
      x = y = 0;
      vscrollbar = "dynamic";
      hscrollbar = "alwaysOff";
 
      new GuiTextListCtrl("ImageViewerList") {
        profile = GuiBlueTextListProfile;
        x = y = 0;
      }
    }
  }
}
 
/*
Gui Actions
*/
 
function ImageViewerSearchBar.onAction() {
  if (ImageViewerSearchBar.text.starts("levels/")) {
    return;
  } else {
    FetchImageList(ImageViewerSearchBar.text);
  }
  ImageViewerSearchBar.text = "";
}
 
function ImageViewerList.onSelect() {
  temp.image = ImageViewerList.selected.text;
  ImageViewerImage.image = temp.image;
  triggerserver("gui",name,"getheightandwidth",ImageViewerList.selected.text);
}
 
function ImageViewerImageBar.onAction() {
  ImageViewerImage.image = ImageViewerImageBar.text;
  triggerserver("gui",name,"getheightandwidth",ImageViewerImageBar.text);
  ImageViewerImageBar.text = "";
}
 
/*
functions
*/
 
function FetchImageList(folder) {
  ImageViewerList.clearrows();
  triggerserver("gui",name,"getfolder",folder);
}
 
/*
action clientside
*/
 
function onActionClientSide() {
  switch(params[0]) {
    case "addfiles":
      ImageViewerList.addrow(0,params[1]);
    break;
    case "setwidthandheight":
      ImageViewerImage.width = params[1];
      ImageViewerImage.height = params[2];
    break;
  }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162