Page 1 of 1

AllIn1 Super Canvas Functionality [Additions at bottom]

PostPosted: Thu Apr 05, 2012 8:06 am
by Hblade
Check out the new AllIn1 System, it features an Earthbound styled window theme, and you can handle multiple windows in 1 canvas, as well as CLICKABLE CHOICES! you can also use hover effects. Please try this demo and see if you like it.

HOW TO USE:
The code is understandable, readable, and easy to use. to use this system, all you need to know is a few basic functions and how to call the array which I'll explain completely.

Functions:
createWindow(x, y, width, height, windowIndex); - draw a window on the screen. windowIndex is the window number, it's important that you don't have the same windowIndex, as you use these index's to place items / content into the window you created.

updateCanvas(); - updates the canvas, place before everything. prettymuch the same as erase(0, 0, 0, 1);

updateDraw(); - use to update the draw, if you want to change a window location, use this. Try to avoid placing this in draw_actor. Putting this in Draw Actor will cause the canvas to constantly update when it doesn't need to, and that would cause a slowdown. Use this if you have an event that brings a window up or something.

saveDraw(); - Use this at the end of the draw_actor area, as it will save every position of the windows and prevent updating it constantly.

sendTo(x_offset, y_offset, window_index); - This will allow you to place content into a window, by default the x and y offsets are already set to fit the window and not stick to it's border, however if you want to text to appear somewhere else on the window, you can use x offset and y offset. window_index is the window that you want to stick it to. (Example in ged file).

hotSpot(X, Y, Width, Height, Index); - This creates a "choice" section, a place where you can hover and click on the canvas. again, index is important, so try not to use the same index.

sendToHotspot(); - This will send text or an object to the hover/click area, aka hotspot.

doClick(hotspot_index); - This is essential for ENABLING the click effect, if you don't put this, then the hotspot will only have a hover effect. Place this in mousedown.

resetActive(); - Use this in mouseup, it resets the active variable that uses the click effect. otherwise, you'd stay clicked unless moved out of the area.

drawObject("actor_name", x_offset, y_offset, scale, windowindex, objectIndex); - This will draw an object on the canvas and stick it to a window of your choice. same offset goes as before. Set the scale to set the size of the drawing, and it uses decimals, so you can use 1.5 or .5 or something like that. windowIndex is the window you want to stick it to. objectIndex uses a variable called obScale, and its meant for storing the scale value if you ever needed to, so be sure to use a different index each time. :)





Calling the arrays:
To determine if a choice was clicked, you can use something like this
Code: Select all
//if First Choice was clicked
if(active[0])
{
    updateDraw();
    varx=25;
    vary=50;
}

//if Second Choice was clicked
if(active[1])
{
    updateDraw();
    varx=50;
    vary=50;
}

See how active[0] is in the if? That means, if the choice area with the index of 0 was clicked. Same with active[1], if the hotspot given the index of 1 was clicked, then it'll do some code.

if this is still confusing, I'll make it simple:
if active[0] means that when you click the choice created like this
Code: Select all
hotSpot(x, y, width, height, 0);

only with actual settings, then it'll do some code. Thats why the index is so important.

Anyways here's the stuff :D Enjoy! :)
winSys.zip
(36.01 KiB) Downloaded 387 times

Screenshot-Game Editor-2.png







SEE IT IN ACTION HERE :D
shoptest.zip
(67.23 KiB) Downloaded 375 times

Screenshot-Game Editor-3.png








Additions:
A namebox code. To use this, add the code under the screenshot anywhere in the global code.
Screenshot-Game Editor-5.png

Code: Select all
void NameBox(char *textactor)
{
    Actor *a=getclone(textactor);
    setpen(64, 25, 44, 0, a->height);
    moveto(a->xscreen, a->yscreen+(a->height/2));
    lineto(a->xscreen+a->width, a->yscreen+(a->height/2));
}


How to use:
NameBox("Name_display_Actor"); - Where ever the text actor is on screen, it will be followed by an equally-sized purplish box. you can stamp something to the top of a window to make a name appear using this.

Re: AllIn1 Super Canvas Functionality [Additions at bottom]

PostPosted: Thu Apr 05, 2012 12:50 pm
by lcl
This is quite interesting, great work! =D

I think you should continue this and make it easy to use so it handles things by itself.
You could make it do things automatically, you could, for example program the window opener function
to also have option to input text which would then be shown in the window and all sorts of things like that.
If you automatize them, I think more people will find use for this, because it would be easier. =D

This inspires me to do some things to the new version of my lclOS. :D

Re: AllIn1 Super Canvas Functionality [Additions at bottom]

PostPosted: Thu Apr 05, 2012 1:27 pm
by SuperSonic
Hey, good job :wink:

I tried making something like this a long time ago but I failed XD

Anyways, +1 for succeeding where I failed :lol:

Re: AllIn1 Super Canvas Functionality [Additions at bottom]

PostPosted: Thu Apr 05, 2012 2:24 pm
by Hblade
lol thanks guys, I ended up loosing track of time and before realizing it, it was like 3:00AM, then I continued till like 5:30AM.

LCL:
How would I do that? =P Maybe perhaps the BMP font thing, but I don't really know how to do that lol. also: I had only 5 hours of sleep xD So my brain isn't functioning at the speed as yesterday/last night xD

EDIT:
actually I do have an idea =)

Re: AllIn1 Super Canvas Functionality [Additions at bottom]

PostPosted: Thu Apr 05, 2012 6:04 pm
by happyjustbecause
Hblade wrote:Check out the new AllIn1 System, it features an Earthbound styled window theme, and you can handle multiple windows in 1 canvas, as well as CLICKABLE CHOICES! you can also use hover effects. Please try this demo and see if you like it.

-------> HO <------ TO USE:
The code is understandable, readable, and easy to use. to use this system, all you need to know is a few basic functions and how to call the array which I'll explain completely.


Sorry to point out a spelling error, but just thought you might want to fix "HO TO USE" to HOW TO USE at the top of the post. I'm going to check out this download though, looks interesting.

Re: AllIn1 Super Canvas Functionality [Additions at bottom]

PostPosted: Thu Apr 05, 2012 6:12 pm
by Hblade
LOL thanks, fixed

Re: AllIn1 Super Canvas Functionality [Additions at bottom]

PostPosted: Thu Apr 05, 2012 6:15 pm
by Hblade
Updated version screenshots:
Screenshot-Game Editor-7.png


Button text always centered, new instant text draw functionality

Re: AllIn1 Super Canvas Functionality [Additions at bottom]

PostPosted: Thu Apr 05, 2012 9:18 pm
by lcl
Hblade wrote:LCL:
How would I do that? =P Maybe perhaps the BMP font thing, but I don't really know how to do that lol. also: I had only 5 hours of sleep xD So my brain isn't functioning at the speed as yesterday/last night xD

I played around with that BMP font loading but it turned out to be a little too slow. It's good if you don't have to do anything else at the same time AND if you want to be able to change the texts colors freely.

But what I found out as a much easier and better solution was to have all the ASCII characters as normal actors animations, so that you have 1 clone for 1 character. You just have to make it so that clone.0 has the animation of the first ASCII character, etc.
Note that you can do this all very easily, just use "Clone" - "Array" to clone the needed amount of those actors and then give them the font as animation. In the create actor event just do this:
Code: Select all
ChangeAnimationDirection("Event Actor", STOPPED);
animpos = cloneindex;

Then you can make a little function that you can input a string into and then the function goes through it, letter by letter and draws the needed character with draw_from()! Easy, isn't it? And you can then use this function in your window opening function and make it print the inputted string! =D

That's actually how the things are done in my new version of lclOS :D

Re: AllIn1 Super Canvas Functionality [Additions at bottom]

PostPosted: Thu Apr 05, 2012 9:25 pm
by skydereign
lcl wrote:
Hblade wrote:LCL:
But what I found out as a much easier and better solution was to have all the ASCII characters as normal actors animations, so that you have 1 clone for 1 character. You just have to make it so that clone.0 has the animation of the first ASCII character, etc.
Note that you can do this all very easily, just use "Clone" - "Array" to clone the needed amount of those actors and then give them the font as animation. In the create actor event just do this:
Code: Select all
ChangeAnimationDirection("Event Actor", STOPPED);
animpos = cloneindex;

Then you can make a little function that you can input a string into and then the function goes through it, letter by letter and draws the needed character with draw_from()! Easy, isn't it? And you can then use this function in your window opening function and make it print the inputted string! =D

That's actually how the things are done in my new version of lclOS :D

I wouldn't recommend using clones for this, solely because all those clones aren't necessary. You can instead send an activation event to a single ascii actor, and in the activation event change its animpos to the ascii character you want. And then call draw_from. Since images from draw_from don't update, you only really need one actor, that you can change its rgb, and character it displays.

Re: AllIn1 Super Canvas Functionality [Additions at bottom]

PostPosted: Thu Apr 05, 2012 9:35 pm
by lcl
skydereign wrote:I wouldn't recommend using clones for this, solely because all those clones aren't necessary. You can instead send an activation event to a single ascii actor, and in the activation event change its animpos to the ascii character you want. And then call draw_from. Since images from draw_from don't update, you only really need one actor, that you can change its rgb, and character it displays.

Oh, why didn't I think of that before?

But what about having many texts on the screen at the same time and if they need to be updated all the time for moving them around?

Re: AllIn1 Super Canvas Functionality [Additions at bottom]

PostPosted: Thu Apr 05, 2012 9:46 pm
by skydereign
lcl wrote:Oh, why didn't I think of that before?

But what about having many texts on the screen at the same time and if they need to be updated all the time for moving them around?

Moving them around? draw_from handles position for you, and all you are doing is changing the frame, and potentially the rgb (which isn't costly at all). But, I guess you are talking about the case where there is thousands of characters, in which it might be better to have the clones. Generally speaking neither method is slow, but as a rule of thumb I tend to keep the number of actors to a minimum. And I believe the point at which you begin to detect lag (really worst case) you would run into it from too many draw_from calls, rather than the number of changing animpos.

Re: AllIn1 Super Canvas Functionality [Additions at bottom]

PostPosted: Sun Jan 27, 2013 12:45 am
by EvanAgain
This is perfect for what I was trying to do as well, Thanks for making this.

Now just to look at the code and experiment with some things to make a different style of menu.

Awesome stuff!

Re: AllIn1 Super Canvas Functionality [Additions at bottom]

PostPosted: Sun Jan 27, 2013 8:07 am
by Hblade
Glad you like =)

Re: AllIn1 Super Canvas Functionality [Additions at bottom]

PostPosted: Wed Mar 20, 2013 2:10 pm
by GEuser
Ooh, missed this. (things get buried if you don't login regularly). I was looking to do similiar stuff but never got around to it. WIll check it out...

Re: AllIn1 Super Canvas Functionality [Additions at bottom]

PostPosted: Wed Mar 20, 2013 3:26 pm
by Hblade
k, hope you enjoy.