Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Showing Text & Images On Screen (https://forums.graalonline.com/forums/showthread.php?t=134267717)

Astram 01-02-2013 10:49 PM

Showing Text & Images On Screen
 
Hey guys!
I'm back to developing and Graal in general. I was wondering how I would approach creating text and images appearing on a screen for a Heads up display. I tried various methods such as with(findimg(200)) {, etc. However the result was showing on X and Y coordinates of the level instead of X and Y coordinates of the players screen. I need a way to approach this, and an easy way too. Also, just an additional question, how would I use catchEvent() to detect if a player clicked on an image/text in the HUD? Anyways this is also my 300th post, so its a double event for me haha. Thanks for helping guys.

callimuc 01-02-2013 10:59 PM

set the layer to 4 or up

PHP Code:

with (findImg(200)) {
  
layer 4;
  
screen_x_here;
  
screen_y_here;
  
text "sup dude";



Astram 01-02-2013 11:01 PM

Quote:

Originally Posted by callimuc (Post 1711422)
set the layer to 4 or up

PHP Code:

with (findImg(200)) {
  
layer 4;
  
screen_x_here;
  
screen_y_here;
  
text "sup dude";



Thanks! Let me try this out! Now all I need is a way to use catchevent for it.

ff7chocoboknight 01-03-2013 06:11 PM

It's always bugged me that you two exist.

fowlplay4 01-03-2013 07:31 PM

Quote:

Originally Posted by ff7chocoboknight (Post 1711469)
It's always bugged me that you two exist.

They have more value in this community than you ever will.

@Astram: You will have to use a GuiShowImgCtrl if you want to 'catchevent' anything related to that image.

ffcmike 01-03-2013 08:25 PM

While using a GUI Control is ideal for stuff related to clicking, with normal displays you could try something such as this:

PHP Code:

//#CLIENTSIDE
function showHUD(){
  
this.addHUDObj(this.showimg(200"image.png"xy), 32324);

  
this.addHUDObj(this.showimg(201"image2.png"xy), 64644);

  
temp.this.showtext(202xy"tempus sans itc""b""text");
  
temp.t.zoom 0.5;
  
temp.gettextwidth(temp.t.zoomtemp.t.fonttemp.t.styletemp.t.text);
  
temp.gettextheight(temp.t.zoomtemp.t.fonttemp.t.styletemp.t.text);
  
this.addHUDObj(temp.ttemp.wtemp.h5);
}

function 
addHUDObj(temp.displaytemp.wtemp.htemp.layer){
  
temp.display.dwidth temp.w;
  
temp.display.dheight temp.h;
  
temp.display.layer temp.layer;
  
this.displays.add(temp.display);
}

function 
onMouseDown(temp.button) {
  if(
temp.button != "left")
    return;

  for(
temp.this.displays){
    if(
      
mousescreenx in <temp.d.xtemp.d.temp.d.dwidth> &&
      
mousescreeny in <temp.d.ytemp.d.temp.d.dheight>
    ){
      
this.startDrag(temp.d);
      return;
    }
  }
}

function 
startDrag(temp.d){
  
this.dragobj temp.d;
  
this.draglayer this.dragobj.layer;
  
this.draglayer 6;
  
this.dragoffx mousescreenx this.dragobj.x;
  
this.dragoffy mousescreeny this.dragobj.y;
  
this.scheduleEvent(0.05"Drag""");
}

function 
onDrag(){
  if(!
leftmousebutton){
    
this.dragobj.layer this.draglayer;
    return;
  }
  
this.dragobj.min(max(0mousescreenx this.dragoffx), screenwidth this.dragobj.dwidth);
  
this.dragobj.min(max(0mousescreeny this.dragoffy), screenheight this.dragobj.dheight);
  
this.scheduleEvent(0.05"Drag""");



callimuc 01-03-2013 08:58 PM

Quote:

Originally Posted by ffcmike (Post 1711481)
While using a GUI Control is ideal for stuff related to clicking, with normal displays you could try something such as this:

PHP Code:

if(
      
mousescreenx in <temp.d.xtemp.d.temp.d.dwidth> &&
      
mousescreeny in <temp.d.ytemp.d.temp.d.dheight>
    ) 


wouldnt it have to be like the following?
PHP Code:

if(
  
mousescreenx in |temp.d.xtemp.d.temp.d.dwidth| &&
  
mousescreeny in |temp.d.ytemp.d.temp.d.dheight|


if not, what would the < > 's do exactly in this case (i know that they can be used for smaller, bigger checks but wouldnt make sense in here like i am used to it)?

ffcmike 01-03-2013 09:03 PM

Quote:

Originally Posted by callimuc (Post 1711484)
wouldnt it have to be like the following?
PHP Code:

if(
  
mousescreenx in |temp.d.xtemp.d.temp.d.dwidth| &&
  
mousescreeny in |temp.d.ytemp.d.temp.d.dheight|


if not, what would the < > 's do exactly in this case (i know that they can be used for smaller, bigger checks but wouldnt make sense in here like i am used to it)?

Using |,| includes the minimum and maximum value, allowing an edge-on intersect, whereas with <,> it has to be within the range. It doesn't matter so much in this case.

DustyPorViva 01-03-2013 09:04 PM

Controls are definitely the way to go if you want to have absolutely any kind of interactive interface. Just remember that controls steal input and therefor if you're creating something like a HUD you have to remember to give focus back to GraalControl and various other things so you don't constantly end up with the whole "I press up but I don't move until I click the screen" situation.

http://forums.graalonline.com/forums...96&postcount=9

Also controls are always on their own higher layer and can never be drawn below showimg() content.

ff7chocoboknight 01-04-2013 05:29 AM

Quote:

Originally Posted by fowlplay4 (Post 1711475)
They have more value in this community than you ever will.

@Astram: You will have to use a GuiShowImgCtrl if you want to 'catchevent' anything related to that image.

I don't care if they are in this community nor do I care about value, I care that they exist.

Tim_Rocks 01-04-2013 08:03 AM

Quote:

Originally Posted by ff7chocoboknight (Post 1711532)
I don't care if they are in this community nor do I care about value, I care that they exist.

http://kentucky.straitpinkie.com/wp-...by-300x300.jpg


All times are GMT +2. The time now is 09:07 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.