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);
        } else {
          echo("Blocked files:" SPC images);
        }
      }
    }
    break;
  }
}
 
//#CLIENTSIDE
function onCreated() {
  drawGUI();
}
 
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 = 400;
      height = 25;
      x = 0;
      y = 200;
      active = true;
    }
    new GuiControl("ImageViewerImageBorder") {
      useownprofile = true;
      width = 275;
      height = 200;
      x = 125;
      y = 0;
      profile.border = 1;
      new GuiShowImgCtrl("ImageViewerImage") {
        width = 275;
        height = 200;
        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;
}
/*
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;
  }
}
  • 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