SRL Archive - MSI Suggestions

MSI Form


Gu3st...

2010-04-28 16:26:14

From: Coh3n
Alright guys, this is close to being done. The rest should be pretty easy. You don't even have to do a lot. Even if you just add one button, that's still good. :) Since ReadySteadyGo seems to have gone inactive, I have made a new SVN with Dan's most recent form script.

https://msiplayerform.googlecode.com/svn/trunk/
Also, the tab plans can be found here.

I'll be able to update the SVN with any changes someone makes, and I'll be more than happy to add you so you can commit, just post your gmail account (or PM me) and I'll make it happen.


Just got rid of the rest of this post (if you saw it before) because it was way outdated. Figured I'd update the information. :)

Cheers,
The MSI Team

Coh3n

2010-04-28 16:27:58

Edited to show the form. That thread was in the SL & PM section. :p

Dan Cardin

2010-04-28 18:55:23

var state: tWindowState;
begin
ClearDebug;
DeclarePlayers;
state := getSelf.WindowState;
GetSelf.WindowState := wsMinimized;
MainMSIForm;
GetSelf.WindowState := state;
end.

also it might make more sense to use a TTabControl and use an array of strings, integers and whatnot for each tab's player info and options seeing as all yours tabs will have the same structure and having a separate tab and objects for each may be excessive.

Coh3n

2010-04-29 08:05:36

From: Dan Cardin

also it might make more sense to use a TTabControl and use an array of strings, integers and whatnot for each tab's player info and options seeing as all yours tabs will have the same structure and having a separate tab and objects for each may be excessive.

Absolutely.

Coh3n

2010-05-30 11:10:02

[BANANA][/BANANA]

[BANANA][/BANANA]


Hopefully someone can work on it now with a rough outline. :) Of course, everything would line up and be much more proportional then those images.

Frement

2010-06-18 15:54:10

From: Zyt3x
A nice design. MSI is awesome and a nice design is a must (!) we could ask Frement to design something for us if we aren't able to make it look nice.


Cool, I can try, anything specific? Like style, coloring, etc.

Coh3n

2010-06-18 15:57:57

From: Frement
Cool, I can try, anything specific? Like style, coloring, etc.

We have a logo already picked out (from the competition a while back), and we may have a background image. I'm going to dig them up in the SL forums right now and edit the first post.

I'm guessing you read this thread:
From: ReadySteadyGo
Hi guys, I've looked through MSI and I'm really impressed and will hopefully be joining development in about a week.

I have a suggestion for the form.

It would be cool to have quite a graphic orientated setup. Rather than defining the different locations with names like VARROCK_EAST_1 etc, you could have that map of all the locations you will be covering. Maybe, when you hover over it with the mouse could give the user info on what trees are there, which bank to start.

Just an idea, not sure if anyone has already thought of it, I just saw the map that Coh3n (i think) made of all the planned locations.


So I think that's a really neat idea, but I'm not sure how to do it properly (or if it can even be done).

But for anything else, the layout I posted above is what we currently have. If it's hard to understand the tabs part, take a look at my Draynor form. It's just basically tabs under tabs (like 2D arrays).

Frement

2010-06-18 16:14:50

From: Coh3n
We have a logo already picked out (from the competition a while back), and we may have a background image. I'm going to dig them up in the SL forums right now and edit the first post.

I'm guessing you read this thread:


So I think that's a really neat idea, but I'm not sure how to do it properly (or if it can even be done).

But for anything else, the layout I posted above is what we currently have. If it's hard to understand the tabs part, take a look at my Draynor form. It's just basically tabs under tabs (like 2D arrays).


Well, everything can be done :) And that would be a very good idea. I'll try to do some graphics of the form today, you got the logo somewhere, link here :)

Coh3n

2010-06-18 16:15:42

Logo's on the first post now. :)

ReadySteadyGo

2010-06-18 18:05:03

cheers for quoting me coh3n, i think that this kind of design thinking could be used throughout like the kind of interface you would see on an iphone, a more interactive way of doing things, so for the selection of skill (this is a multiskill script after all) you could have the skill buttons and have the currently saved skill look active (pushed down) and have these images acting as radio buttons.

Coh3n

2010-06-18 18:08:13

From: ReadySteadyGo
cheers for quoting me coh3n, i think that this kind of design thinking could be used throughout like the kind of interface you would see on an iphone, a more interactive way of doing things, so for the selection of skill (this is a multiskill script after all) you could have the skill buttons and have the currently saved skill look active (pushed down) and have these images acting as radio buttons.

I don't know what you mean by "images acting as radio buttons".

ReadySteadyGo

2010-06-18 18:59:49


Just a mock up so you can see what I mean coh3n.

I'm having quite a few ideas, sliding panels etc. which from the scar games that I've seen made are definitely possibly in the canvas.

edit: The design at the top of this thread might be difficult to work with. It should be bigger imo.

What's great about this project is it's almost like a piece of software in itself so I think it should look a lot cleaner. It could have a news tab and an update script button as well.

Coh3n

2010-06-18 19:04:38

Hmm that's actually really cool, can you do sliding panels in Pascal?

ReadySteadyGo

2010-06-18 19:17:05

Well you'd just make a loop and move the objects left/right 1px - this looped about every 5ms will give you the effect. I'm pretty sure people have made SCAR games using this. Let me find you an example of what I was thinking.

edit:

http://jqueryui.com/demos/accordion/

That but horizontally. might be quite nice like that actually.

Coh3n

2010-06-18 20:06:50

From: ReadySteadyGo
Well you'd just make a loop and move the objects left/right 1px - this looped about every 5ms will give you the effect. I'm pretty sure people have made SCAR games using this. Let me find you an example of what I was thinking.

edit:

http://jqueryui.com/demos/accordion/

That but horizontally. might be quite nice like that actually.

As long as it doesn't hog the CPU I don't see why it wouldn't work.

Gu3st...

2010-06-18 20:22:57

From: ReadySteadyGo
Well you'd just make a loop and move the objects left/right 1px - this looped about every 5ms will give you the effect. I'm pretty sure people have made SCAR games using this. Let me find you an example of what I was thinking.
I've made a lot of games like that. Definitely possible :)
Cool idea

ReadySteadyGo

2010-06-18 20:41:57

Yep, I've done it in python. I think what might be tricky managing which tabs are on top of which for the animation.

Edit: Do we have to stick with that background design?

Frement

2010-06-18 20:51:39

From: ReadySteadyGo
Yep, I've done it in python. I think what might be tricky managing which tabs are on top of which for the animation.

Edit: Do we have to stick with that background design?


I can make similar, larger?

ReadySteadyGo

2010-06-18 21:31:08

I was hoping something cleaner, but it's up to the msi devs.

We need to design it in a way that you still have different players in different locations but also so you can explore the available locations/skills in the 'viewer'. Anyone have any ideas?

Frement

2010-06-18 21:39:57

From: ReadySteadyGo
I was hoping something cleaner, but it's up to the msi devs.

We need to design it in a way that you still have different players in different locations but also so you can explore the available locations/skills in the 'viewer'. Anyone have any ideas?


Well, when selecting locations, expand the form horizontally? A slide effect on that would be cool also, but just quick expanding is good also.

Dan Cardin

2010-06-18 21:56:24

Something that might be a bit annoying is that there's no support for drawing on tabs (as far as I have been able to accomplish) So you'll be stuck with using things that don't blend with the rest of the form. You could probably make your own of everything else, but tabs….

Frement

2010-06-18 22:23:39

Heres something I made quick:

ReadySteadyGo

2010-06-18 22:43:03

Sweet so it can be enlarged without too much sweat.

I quite like the idea of a really user friendly interface.

Probably no one will like this design but it's an idea so you can sort of see what I have in my head.


So each time you complete a form you click the next step and it the panel will slide to the other side revealing stuff you need to input.

The form will dynamically change, depending on the options selected so the next tab will be specific to the user choices.

MylesMadness

2010-06-18 22:44:24

From: ReadySteadyGo
Sweet so it can be enlarged without too much sweat.

I quite like the idea of a really user friendly interface.

Probably no one will like this design but it's an idea so you can sort of see what I have in my head.


So each time you complete a form you click the next step and it the panel will slide to the other side revealing stuff you need to input.

The form will dynamically change, depending on the options selected so the next tab will be specific to the user choices.

Holy crap thats cool, holy crap thats hard to pull off

BobboHobbo

2010-06-18 22:45:40

From: ReadySteadyGo
Sweet so it can be enlarged without too much sweat.

I quite like the idea of a really user friendly interface.

Probably no one will like this design but it's an idea so you can sort of see what I have in my head.


So each time you complete a form you click the next step and it the panel will slide to the other side revealing stuff you need to input.

The form will dynamically change, depending on the options selected so the next tab will be specific to the user choices.


Im really liking your idea.

Coh3n

2010-06-19 00:07:33

From: Dan Cardin
Something that might be a bit annoying is that there's no support for drawing on tabs (as far as I have been able to accomplish) So you'll be stuck with using things that don't blend with the rest of the form. You could probably make your own of everything else, but tabs….

You can always make custom tabs using images (check out my Draynor Chop N' Bank form for a good example).

From: Frement
Heres something I made quick:

The lettering of MSI itself needs to stay the same as the one in the first post, as it was the competition winner.

@ReadySteadyGo: I like your first layout better (with the skill logo buttons and world map). But your second idea is cool, but if we decide to go with it, I'm not letting you use those colours. :p

ReadySteadyGo

2010-06-19 00:28:21

The colours were the best bit :P Who wants text. If there is a red button, you're gonna click it lets face it :)

Yeh that's fine, it was just a mock up.

I don't have a windows machine for a week so i'm just figuring out the most efficient way to do the previous idea, I reckon it's possible:


From: Nava2
why the hell would you focus on a form.
honest the frontend is the last part of the project that shoudl be worried about. the focus on front-end is disgusting, lok at the backend, and making software work well. There it nothing better than a good front end, rather than a front-end.

GUI SUCKS. End fo stry.


chill out man. it's not like all the MSI designers are running off to do the form. it's just me, who wasn't even involved in msi and had an idea which i want to try.

Coh3n

2010-06-19 07:19:04

From: ReadySteadyGo
The colours were the best bit :P Who wants text. If there is a red button, you're gonna click it lets face it :)

Yeh that's fine, it was just a mock up.

I don't have a windows machine for a week so i'm just figuring out the most efficient way to do the previous idea, I reckon it's possible:


I would like to see more "Runescape" type colours. Like different shades of brown or parts taken from the game (i.e. the bank border, the skill info. scrolls, etc.).

Gu3st...

2010-06-19 07:40:16

From: MylesMadness
Holy crap thats cool, holy crap thats hard to pull off
Not that hard to do :)

Sir R. M8gic1an

2010-06-19 15:03:00

A big thumbs up for user friendliness. I loved the map. Might be a bit complicated to do it for each player?

Idea:

form 1: Player setup
form 2: (* TotalPlayers): Location checklist
form 3: Picking the skills/scripts for each location (has to accept more than one)
form 4: Just a 'debug' of all the stuff, for the user to confirm all the info is correct?

@Coh3n: The post you made about scripts vs skills should probably be moved to public soon ;)

~RM

Coh3n

2010-06-20 19:59:30

From: Rasta Magician
A big thumbs up for user friendliness. I loved the map. Might be a bit complicated to do it for each player?

Idea:

form 1: Player setup
form 2: (* TotalPlayers): Location checklist
form 3: Picking the skills/scripts for each location (has to accept more than one)
form 4: Just a 'debug' of all the stuff, for the user to confirm all the info is correct?

@Coh3n: The post you made about scripts vs skills should probably be moved to public soon ;)

~RM

Will do, and the rest sounds pretty good. I like the confirmation page idea. :)

Dan Cardin

2010-06-20 21:10:38

When you say form 1 and on, i hope you don't mean seperate forms. Cuz that is annoying. I rather hope you are talking about his page idea thing.

coh3n - i cannot download your script, couldst thou screenshot it for me?

Coh3n

2010-06-20 21:35:07

From: Dan Cardin
When you say form 1 and on, i hope you don't mean seperate forms. Cuz that is annoying. I rather hope you are talking about his page idea thing.

coh3n - i cannot download your script, couldst thou screenshot it for me?

I'm assuming that's what he was talking about, and here:


Sir R. M8gic1an

2010-06-21 05:40:01

@Dan: yes, I mean his page idea. It's what was on topic, I wasn't pulling in a completly random idea when there was already something that would have the same end result and be more effective.

@Coh3n: Damn nice form.

~RM

3Garrett3

2010-06-21 05:43:37

@Cohen,

That form blew my mind. I never even knew that was possible.

Coh3n

2010-06-21 06:01:51

@RM & Garrett: You should download and check out all the features. ;) I'm pretty proud of it, I must say. :)

Dan Cardin

2010-06-21 06:50:54

RM - yea, i was about to continue saying why multiple forms were silly when i realized who posted and was like…he's not stupid, why would he say something like that! then i realized :)

coh3n - what does it look like with like…10 player tabs?

I would just say use that or something very similar to that, but I do like the ReadySteadyGo's idea because its very procedural for the user and i think it would be very intuitive/easy to use if done correctly.

marpis

2010-06-21 09:54:17

Just a random comment:
We have great ideas and even better codewriters*Coh3n*, so we have all the possibilities to get a very nice and userfriendly form in MSI.

And that's what we must have. After we have like 3-5 skills and/or locations supported and working "flawlessly" we will want to start campaigning (?) MSI very publicly. But before any new users will even try MSI, they must be provided with a playerform. Text-based player declaration and setup is easy and efficient for single scripts that only require little info. MSI needs so many things to be clarified to the script that it's one big mess if you don't already know SRL and pascalscript.

So those of you who know something about forms in pascal but don't want/can write the actual autoing functions, please start making code scetches for MSI playerform!

And most importantly: The looks is not important. It has to be easy and clear, that's all we can require if we ever want to see a form in MSI. If it looks good is just a plus.

ReadySteadyGo

2010-06-21 10:08:54

I've started my accordion script. I have it all down it just seems to be slow but that might be down to the fact that I'm using a VMware to use scar. Can anyone test it for me? My msn is [email]jackshannon1@googlemail.com[/email]

Edit: Coh3n, I love the Graphics on that, if I give you a wireframe when I'm done with the accordion (if you want to use it that is) could you make the same sort of thing again?

ReadySteadyGo

2010-06-21 10:17:34

program FormAccordion;

var
b, w, h, i: Integer;
MainForm: TForm;
Tab: Array of TImage;
Tab_State: Array of Integer;

const
Tab_Amount = 4; // Number of tabs

Tab_1 = 0;
Tab_2 = 1;
Tab_3 = 2;
Tab_4 = 3;

Dir_Left = 0;
Dir_Right = 1;

Tab_State_Right = 0;
Tab_State_Left = 1;

procedure SlideTab(Sender: TObject; WhichTab: Integer);
var
NewPos, Movements: Integer;
begin
case Tab_State[WhichTab] of
Tab_State_Right:
begin
NewPos := WhichTab * 60;
WriteLn(NewPos);
Movements := (Tab[WhichTab].Left - NewPos) / 20; // How many times it needs to reach NewPos
WriteLn(Movements);
for i := 1 to Movements do
begin
Tab[WhichTab].Left := Tab[WhichTab].Left - 20;
wait(1);
end;
Tab_State[WhichTab] := Tab_State_Left;
end;
Tab_State_Left:
begin
NewPos := MainForm.Width - ((Tab_Amount - WhichTab) * 60); //
WriteLn(NewPos);
Movements := (NewPos - Tab[WhichTab].Left) / 20; // How many times it needs to reach NewPos
WriteLn(Movements);
for i := 1 to Movements do
begin
Tab[WhichTab].Left := Tab[WhichTab].Left + 20;
wait(1);
end;
Tab_State[WhichTab] := Tab_State_Right;
end;
end;
end;

procedure TabClick(Sender: TObject);
var
WhichTab, j: Integer;
begin
for i := 0 to (Tab_Amount - 1) do
if (Sender = Tab[i]) then
WhichTab := i;
//WriteLn(WhichTab);
case Tab_State[WhichTab] of
Tab_State_Right:
for j := 0 to WhichTab do
if (Tab_State[j] = Tab_State_Right) then
SlideTab(Tab[j], j);
Tab_State_Left:
for j := (Tab_Amount - 1) downto WhichTab do
if (Tab_State[j] = Tab_State_Left) then
SlideTab(Tab[j], j);
end;
end;

procedure InitForm;
begin
MainForm := CreateForm;
with MainForm do
begin
Position := poScreenCenter;
Width := 600;
Height := 700;
Caption := 'FormAccordion';
Color := 3416346;
end;

SetArrayLength(Tab, Tab_Amount);
b := loadbitmap('C:\Documents and Settings\Administrator\Desktop\MSIForm/Tab.bmp');
getbitmapsize(b, w, h);
for i := High(Tab) downto 0 do
begin
Tab[i] := TImage.Create(MainForm);
with Tab[i] do
begin
Parent := MainForm;
Left := MainForm.Width - ((Tab_Amount - i) * 60); // MainForm.Width seeems to be inaccurate.
Top := 30;
Width := 60;
Height := 410;
OnClick := @TabClick;
end;
copycanvas(getbitmapcanvas(b), Tab[i].canvas, 0, 0, w, h, 0, 0, w, h);
end;
end;

procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;

procedure ShowFormModal;
begin
MainForm.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;

begin
SetArrayLength(Tab_State, 4);
for i := Tab_1 to Tab_4 do
Tab_State[i] := Tab_State_Right;

SafeInitForm;
SafeShowFormModal;
end.

EDIT BY ZYT3X:
Simba version:
program FormAccordion;

var
b, w, h, i: Integer;
MainForm: TForm;
Tab: Array of TImage;
Tab_State: Array of Integer;

const
Tab_Amount = 4; // Number of tabs

Tab_1 = 0;
Tab_2 = 1;
Tab_3 = 2;
Tab_4 = 3;

Dir_Left = 0;
Dir_Right = 1;

Tab_State_Right = 0;
Tab_State_Left = 1;

procedure SlideTab(Sender: TObject; WhichTab: Integer);
var
NewPos, Movements: Integer;
begin
case Tab_State[WhichTab] of
Tab_State_Right:
begin
NewPos := WhichTab * 60;
WriteLn(NewPos);
Movements := (Tab[WhichTab].Left - NewPos) / 20; // How many times it needs to reach NewPos
WriteLn(Movements);
for i := 1 to Movements do
begin
Tab[WhichTab].Left := Tab[WhichTab].Left - 20;
wait(1);
end;
Tab_State[WhichTab] := Tab_State_Left;
end;
Tab_State_Left:
begin
NewPos := MainForm.Width - ((Tab_Amount - WhichTab) * 60); //
WriteLn(NewPos);
Movements := (NewPos - Tab[WhichTab].Left) / 20; // How many times it needs to reach NewPos
WriteLn(Movements);
for i := 1 to Movements do
begin
Tab[WhichTab].Left := Tab[WhichTab].Left + 20;
wait(1);
end;
Tab_State[WhichTab] := Tab_State_Right;
end;
end;
end;

procedure TabClick(Sender: TObject);
var
WhichTab, j: Integer;
begin
for i := 0 to (Tab_Amount - 1) do
if (Sender = Tab[i]) then
WhichTab := i;
//WriteLn(WhichTab);
case Tab_State[WhichTab] of
Tab_State_Right:
for j := 0 to WhichTab do
if (Tab_State[j] = Tab_State_Right) then
SlideTab(Tab[j], j);
Tab_State_Left:
for j := (Tab_Amount - 1) downto WhichTab do
if (Tab_State[j] = Tab_State_Left) then
SlideTab(Tab[j], j);
end;
end;

procedure InitForm;
begin
MainForm := TForm.Create(nil);
with MainForm do
begin
Position := poScreenCenter;
Width := 600;
Height := 700;
Caption := 'FormAccordion';
Color := 3416346;
end;

SetArrayLength(Tab, Tab_Amount);
b := createbitmap(600, 700);
getbitmapsize(b, w, h);
for i := High(Tab) downto 0 do
begin
Tab[i] := TImage.Create(MainForm);
with Tab[i] do
begin
Parent := MainForm;
Left := MainForm.Width - ((Tab_Amount - i) * 60); // MainForm.Width seeems to be inaccurate.
Top := 30;
Width := 60;
Height := 410;
OnClick := @TabClick;
end;
DrawBitmap(b, Tab[i].canvas, 0, 0);
end;
end;

procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;

procedure ShowFormModal;
begin
MainForm.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;

begin
SetArrayLength(Tab_State, 4);
for i := Tab_1 to Tab_4 do
Tab_State[i] := Tab_State_Right;

SafeInitForm;
SafeShowFormModal;
end.

Gu3st...

2010-06-21 10:43:13

Cool, ReadySteadyGo :) Good job :)

ReadySteadyGo

2010-06-21 13:19:29

Cheers :)

Here is my new design, I'm going to play around with a banner.


Coh3n

2010-06-21 18:03:29

From: Dan Cardin
RM - yea, i was about to continue saying why multiple forms were silly when i realized who posted and was like…he's not stupid, why would he say something like that! then i realized :)

coh3n - what does it look like with like…10 player tabs?

I would just say use that or something very similar to that, but I do like the ReadySteadyGo's idea because its very procedural for the user and i think it would be very intuitive/easy to use if done correctly.

Yeah that's the only thing I don't like about my form, I could never (not that I really tried hard) to get more than 6 tabs working properly. That's why I kept the option to use DeclarePlayers for the people with more than 6 players.

From: marpis
Just a random comment:
We have great ideas and even better codewriters*Coh3n*, so we have all the possibilities to get a very nice and userfriendly form in MSI.

And that's what we must have. After we have like 3-5 skills and/or locations supported and working "flawlessly" we will want to start campaigning (?) MSI very publicly. But before any new users will even try MSI, they must be provided with a playerform. Text-based player declaration and setup is easy and efficient for single scripts that only require little info. MSI needs so many things to be clarified to the script that it's one big mess if you don't already know SRL and pascalscript.

So those of you who know something about forms in pascal but don't want/can write the actual autoing functions, please start making code scetches for MSI playerform!

And most importantly: The looks is not important. It has to be easy and clear, that's all we can require if we ever want to see a form in MSI. If it looks good is just a plus.

That's what I was trying to say when I posted a template, but to be honest, I like the way things are going right now. These guys seem to be really in to it. I want to see how it turns out.

From: ReadySteadyGo
I've started my accordion script. I have it all down it just seems to be slow but that might be down to the fact that I'm using a VMware to use scar. Can anyone test it for me? My msn is [email]jackshannon1@googlemail.com[/email]

Edit: Coh3n, I love the Graphics on that, if I give you a wireframe when I'm done with the accordion (if you want to use it that is) could you make the same sort of thing again?

I've added you on MSN, and what graphics do you mean? From the posts you've made it seems like you know what you're doing when it comes to graphics. :rolleyes:

From: ReadySteadyGo
Cheers :)

Here is my new design, I'm going to play around with a banner.


LOVE IT! Looks really awesome! Remember, make sure you use the Logo posted above as it was a competition winner. If you want to slightly modify it, see if you can get permission from jimmy_mac, or even have rotating banners if you wish.

Dan Cardin

2010-06-21 23:51:51

I dont know if its just me but i think it might make some sense to take this time to try designing a new srl playerform. That's not the direction that this seems to be taking (because of all of the images) but i suppose if you make a flexible enough base, it could be possible to make an srl playerform that can be dynamic to the script. I dunno if anyone else agrees but i think it would be a nice way to kill two birds with one stone.

marpis

2010-06-22 02:03:57

From: Dan Cardin
I dont know if its just me but i think it might make some sense to take this time to try designing a new srl playerform. That's not the direction that this seems to be taking (because of all of the images) but i suppose if you make a flexible enough base, it could be possible to make an srl playerform that can be dynamic to the script. I dunno if anyone else agrees but i think it would be a nice way to kill two birds with one stone.


Too bad that won't be quite possible. SRL playerform needs to be 100% customizeable and text-based, while now we are leaning towards using a map as a location definer. And many of us also like ReadySteadyGo's idea (the accordion) which also wouldn't be that useful in the SRL-form.

E: Oh, you werent trying to say that we should make a new SRL-form and use it in MSI. :p lol.

Dan Cardin

2010-06-22 08:32:26

I wasn't?

marpis

2010-06-22 08:41:37

From: Dan Cardin
I wasn't?


Lol :p Anyways, you got my point.

Dan Cardin

2010-06-22 16:35:39

the thing is that right now, the playerform is barely customizable at all. I was suggesting fixing that and kind of going away from the all image form we have planned here.

Coh3n

2010-06-22 17:51:30

From: Dan Cardin
the thing is that right now, the playerform is barely customizable at all. I was suggesting fixing that and kind of going away from the all image form we have planned here.

That was the original plan (excluding the updating of SRL's playerform), but seeing as there are a lot of people interested in this, and ReadySteadyGo seems pretty motivated to write this form, I want to see how it goes. :)

If you want to change SRL's playerform, go ahead. If you do, post it in the SVN and I, along with the other Dev's will take a look at it. :)

Sir R. M8gic1an

2010-06-22 19:21:30

Why would we need it to be customizable, if it's geared towards MSI ? The fact that we're "gearing" it already makes it a customization..

~RM

King of Knives

2010-06-22 19:38:00

Making a dynamic form that should work for both SRL and MSI would put limitations on the MSI-form. And from what I've seen in this thread, that would be really, really sad. You're brewing on some, quite frankly, awesome ideas and designs. I think you should really stick to making the MSI-form since you have the ideas, the graphics and the coders for it ;)

Eat limitations, shit possibilities :D

Just my input.

-Knives

ReadySteadyGo

2010-06-22 20:10:43

Here is an svn checkout, could someone test it out because I'm using VMware so I have no idea what performance is like.

I've completely rewritten the previous version, coh3n's (nava2's as well?) idea for using array of Boolean alongside constants makes everything so much better.

https://msiform.googlecode.com/svn/trunk/

edit: While I'm at it, I'll post my design for the panels, let me know if anything's missing. http://img691.imageshack.us/img691/4224/formsp.jpg

i luffs yeww

2010-06-22 20:41:05

^ http://goo.gl/83p7

Sabzi

2010-06-22 20:47:19

^ The same for me except that it's much slower for me.
And I got a good enough computer to run a game like MW2 with nice graphics :S.

Although it got something nowadays :(. (sometimes it's hell slow)

ReadySteadyGo

2010-06-22 20:53:55

From: i luffs yeww
^ http://goo.gl/83p7


that looks better than i was expecting, perhaps too fast, if anyone wants to play around and let me know some good values to use. it's pointless me trying to work it out on vmware.

cheers i luffs yeww, really appreciated.

i luffs yeww

2010-06-22 21:03:26

Sabzi said it went slow for him, which seems odd.. I dunno. I'll see if there's anything I can do, but I doubt it (as it already works fine for me).

Also, I think that with the map and everything there it will slow down some, and would prove to make a better test.

MylesMadness

2010-06-22 21:07:14

In the current state its not laggy for me

Coh3n

2010-06-23 06:12:47

Works perfect for me. :) ReadySteadyGo, this is looking really nice so far. I love it! I also like how you've used a lot from my form as reference. I'm glad someone's learning from it. :)

Keep it up!

E: A couple suggestions:
  • Maybe have the active panel highlighted? Or kept as the "hovered" version when active.
  • I'm not sure how much I like the logo with that background. =\ Maybe someone can make a variation that blends in better?

Sabzi

2010-06-23 06:22:55

From: i luffs yeww
Sabzi said it went slow for him, which seems odd.. I dunno.


Hmm, now it's working fine. I really have to do some maintenance with my machine :S. I quiet left it alone because of exams :(.

Point of the post: disregard my previous post.

Sir R. M8gic1an

2010-06-23 06:40:29

Looking great.

A couple things:
I agree with Coh3n's idea of 'highlighting' the active panel.
I think the active panel should be the first one on the right:
- Meaning that when you first open it, you are already on panel 1, therefore it is not 'clickable'.
- I would rather it started on panel 0, and have panel 1 being the first set up page. Panel 0 could have some introductory text for MSI.

How I see it:
  • Open form
  • Panel 0: Introduction text, 'please click panel 1 to continue'
  • Panel 1: DeclarePlayers
  • Panel 2: Name of player on top, with a 'next' and 'previous' arrow to change player
    • DropDown list of cities MSI currently supports
    • Show the MSI Maps of that city (only showing the currently supported banks & skill spots)
    • User clicks on the bank. For this, two debug boxes:
      1. Instructions debug box: 'Please click the bank where the player currently is
      2. Bank: Varrock East Bank
    • More instructions as each step is completed, more information debugged
  • Panel 3: Debug of all the players' setups, ask to confirm
  • Panel 4: Script Setup (SRL Stats username, customizable stuff, etc)
  • Panel 5: General Help / FAQ / Further info / whatever

How does that sound?

~RM

Sabzi

2010-06-23 07:22:39

I think" General Help / FAQ / Further info / whatever" should be more separated.
All the previous panels are like steps as you go further in setting up the script.
That panel 5 doesn't really fit in this. It should be more on it's own. But that's just my opinion.

Sir R. M8gic1an

2010-06-23 07:31:15

How about a 'thank you for using MSI panel', with a bunch of 'links' to the other stuff?

Feedback thread, FAQ, etc.

~RM

Sabzi

2010-06-23 07:59:17

From: Rasta Magician
How about a 'thank you for using MSI panel', with a bunch of 'links' to the other stuff?

Feedback thread, FAQ, etc.

~RM


That sounds great to me. It's more in the steps this was as using is the final step.

marpis

2010-06-23 09:38:26

From: i luffs yeww
^ http://goo.gl/83p7


Oh my god. That's just… so… :norris:.
How can you guys even make these awesome forms?

Coh3n and luffs, you're the best.

ReadySteadyGo

2010-06-25 10:29:13

update: location viewer added :)

https://msiform.googlecode.com/svn/trunk/

Dan Cardin

2010-06-25 10:41:52

the form shouldnt work like it does now. Right now, if you click tab 1 it puts tab 1 on the left. Then if you go all the way to 4, then realize, oh hey i need to change something in declar players (according to RM's plan, tab 1) and you click on it, it puts tab 1 on the right, grouped with the others.

ReadySteadyGo

2010-06-25 10:49:04

From: Dan Cardin
the form shouldnt work like it does now. Right now, if you click tab 1 it puts tab 1 on the left. Then if you go all the way to 4, then realize, oh hey i need to change something in declar players (according to RM's plan, tab 1) and you click on it, it puts tab 1 on the right, grouped with the others.


Agreed. I'll change it when I get time.

Coh3n

2010-06-25 11:02:23

This also happens: http://i46.tinypic.com/zu44cl.png. That can be fixed by displaying the "unhovered" tab image on all the tabs that the mouse isn't on when the mouse is on a tab (that may have sounded really confusing).

I (think) I suggested this to you, but I don't remember: Make the map bigger :) Oh, and as you have it now it moves the map after you click and drag. If you change the images coordinates to the mouse position as you move the mouse (OnMouseMove) it will move the map as you move the mouse instead of after (like the world map in the actual game)

Dan Cardin

2010-06-25 11:18:18

Declare players
Player specific settings.
those are what i think would look nice. You might run into problems of a limit to the number of players you can display, but with some creative arrow button making or form resizing, or button resizing, it might still work.

EDIT: the first picture isnt showing up for me, so http://i48.tinypic.com/28245qx.jpg

ReadySteadyGo

2010-06-25 11:20:27

From: Coh3n
This also happens: http://i46.tinypic.com/zu44cl.png. That can be fixed by displaying the "unhovered" tab image on all the tabs that the mouse isn't on when the mouse is on a tab (that may have sounded really confusing).

I (think) I suggested this to you, but I don't remember: Make the map bigger :) Oh, and as you have it now it moves the map after you click and drag. If you change the images coordinates to the mouse position as you move the mouse (OnMouseMove) it will move the map as you move the mouse instead of after (like the world map in the actual game)


Hovering is fixed. Map will be bigger when I get a bit of time, it's quite complicated getting it to sync with the navigator. I will try and get smooth mouse dragging, but I reckon the refresh rate of forms isn't good enough. :)


Dan:
i don't understand? please explain more?

MylesMadness

2010-06-25 11:23:11

I think he was giving a sugestion for how the declare players could look without it being over crowded.

Also I have shiny new stuff for the panning of the map, so if you can get on msn…

Coh3n

2010-06-25 11:39:13

From: ReadySteadyGo
Hovering is fixed. Map will be bigger when I get a bit of time, it's quite complicated getting it to sync with the navigator. I will try and get smooth mouse dragging, but I reckon the refresh rate of forms isn't good enough. :)

Maybe, but worth a shot. :p

Coh3n

2010-06-25 11:41:25

From: MylesMadness
Ready, if you get on msn I got the panning finished…

Post it? :rolleyes:

MylesMadness

2010-06-25 11:43:18

From: Coh3n
Post it? :rolleyes:
1. Sorry about deleting that post, completely forgot I had posted that before.
2.
program MSIForm;

const


PANEL_COUNT = 5;
PANEL_1 = 0;
PANEL_2 = 1;
PANEL_3 = 2;
PANEL_4 = 3;
PANEL_5 = 4;


IMG_COUNT = 23;
// Used in frmMain
IMG_BGND = 0;
IMG_X_NORM = 1;
IMG_Q_NORM = 2;
IMG_LOAD_TAB_NORM = 3;
IMG_SAVE_TAB_NORM = 4;
IMG_TAB_NORM_1 = 5;
IMG_TAB_NORM_2 = 6;
IMG_TAB_NORM_3 = 7;
IMG_TAB_NORM_4 = 8;

IMG_LOC_MAP = 9;
IMG_LOC_NAV = 10;
IMG_LOC_EXIT_NORM = 11;
IMG_LOC_BORD_TOP = 12;
IMG_LOC_BORD_BOTTOM = 13;
IMG_LOC_BORD_LEFT = 14;
IMG_LOC_BORD_RIGHT = 15;
IMG_LOC_BOX_TOP = 16;
IMG_LOC_BOX_LEFT = 17;
IMG_LOC_BOX_RIGHT = 18;
IMG_LOC_BOX_BOTTOM = 19;

// Used in Panel 0 (Is also used for frmMain)
IMG_LOC_ICON_NORM = 20;
IMG_LOC_LABEL = 21;
IMG_TAB_HINT = 22;

// Used in Panel 1

// Used in Panel 2

// Used in Panel 3

// Used in Panel 4

BITMAP_COUNT = 31;
BGND = 0;
X_NORM = 1;
X_HOVER = 2;
Q_NORM = 3;
Q_HOVER = 4;
LOAD_TAB_NORM = 5;
LOAD_TAB_HOVER = 6;
SAVE_TAB_NORM = 7;
SAVE_TAB_HOVER = 8;
TAB_NORM_1 = 9;
TAB_NORM_2 = 10;
TAB_NORM_3 = 11;
TAB_NORM_4 = 12;
TAB_HOVER_1 = 13;
TAB_HOVER_2 = 14;
TAB_HOVER_3 = 15;
TAB_HOVER_4 = 16;
LOC_ICON_NORM = 17;
LOC_ICON_HOVER = 18;
LOC_MAP = 19;
LOC_NAV = 20;
LOC_EXIT_NORM = 21;
LOC_EXIT_HOVER = 22;
LOC_BORD_TOP = 23;
LOC_BORD_BOTTOM = 24;
LOC_BORD_LEFT = 25;
LOC_BORD_RIGHT = 26;
LOC_BOX_TOP = 27;
LOC_BOX_LEFT = 28;
LOC_LABEL = 29;
TAB_HINT = 30;

var
frmMain: TForm;

tImages: Array[0..IMG_COUNT - 1] of TImage;

frmBitmaps: Array [0..BITMAP_COUNT - 1] of Integer;

isActiveImage: Array[0..IMG_COUNT - 1] of Boolean;
isLeftTab: Array[IMG_TAB_NORM_1..IMG_TAB_NORM_4] of Boolean;
isActivePanel: Array[0..PANEL_COUNT - 1] of Boolean;

MapDragStartX, MapDragStartY: Integer;


procedure OnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
MapDragStartX:=x;
MapDragStartY:=y;
end;


procedure OnMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var
xdif, ydif: Integer;
begin
if not IsMouseButtonDown(1) then exit;
xdif := x - MapDragStartX;
ydif := y - MapDragStartY;
tImages[IMG_LOC_MAP].Left := tImages[IMG_LOC_MAP].Left + xdif;
tImages[IMG_LOC_MAP].Top := tImages[IMG_LOC_MAP].Top + ydif;

if tImages[IMG_LOC_MAP].Left > 0 then
tImages[IMG_LOC_MAP].Left := 0;
if tImages[IMG_LOC_MAP].Top > 0 then
tImages[IMG_LOC_MAP].Top := 0;
if tImages[IMG_LOC_MAP].Left < -345 then
tImages[IMG_LOC_MAP].Left := -345;
if tImages[IMG_LOC_MAP].Top < -354 then
tImages[IMG_LOC_MAP].Top := -354;

with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} -tImages[IMG_LOC_MAP].Left / 4 + 376, {T} -tImages[IMG_LOC_MAP].Top / 4 + 216, {W} 110, {H} 1);

if tImages[IMG_LOC_BOX_TOP].Left < 376 then
tImages[IMG_LOC_BOX_TOP].Left := 376;
if tImages[IMG_LOC_BOX_TOP].Top < 216 then
tImages[IMG_LOC_BOX_TOP].Top := 216;
if tImages[IMG_LOC_BOX_TOP].Left > 466 then
tImages[IMG_LOC_BOX_TOP].Left := 466;
if tImages[IMG_LOC_BOX_TOP].Top > 295 then
tImages[IMG_LOC_BOX_TOP].Top := 295;

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 80);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 109, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 80);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 80, {W} 110, {H} 1);

end;

procedure Navigator(Sender: TObject);
var
x, y: Integer;
begin
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x - 55 - 100, {T} y - 40 - 100, {W} 110, {H} 1);

if tImages[IMG_LOC_BOX_TOP].Left < 376 then
tImages[IMG_LOC_BOX_TOP].Left := 376;
if tImages[IMG_LOC_BOX_TOP].Top < 216 then
tImages[IMG_LOC_BOX_TOP].Top := 216;
if tImages[IMG_LOC_BOX_TOP].Left > 466 then
tImages[IMG_LOC_BOX_TOP].Left := 466;
if tImages[IMG_LOC_BOX_TOP].Top > 295 then
tImages[IMG_LOC_BOX_TOP].Top := 295;

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 80);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 109, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 80);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 80, {W} 110, {H} 1);

tImages[IMG_LOC_MAP].Left := -(x - 155 - 376) * 4;
tImages[IMG_LOC_MAP].Top := -(y - 140 - 216) * 4;

if tImages[IMG_LOC_MAP].Left > 0 then
tImages[IMG_LOC_MAP].Left := 0;
if tImages[IMG_LOC_MAP].Top > 0 then
tImages[IMG_LOC_MAP].Top := 0;
if tImages[IMG_LOC_MAP].Left < -345 then
tImages[IMG_LOC_MAP].Left := -345;
if tImages[IMG_LOC_MAP].Top < -354 then
tImages[IMG_LOC_MAP].Top := -354;
end;


procedure TabClick(Sender: TObject);
var
senderTab, i, j, CurrentPanel: Integer;
begin

for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_4 do
if (Sender = tImages[i]) then
senderTab := i;

if not(isLeftTab[senderTab]) then
begin
for i := IMG_TAB_NORM_1 to senderTab do
begin
if not(isLeftTab[i]) then
for j := 1 to 39 do
begin
tImages[i].Left := tImages[i].Left - 10;
Wait(1);
end;

isLeftTab[i] := True;

end;
CurrentPanel := sendertab - IMG_TAB_NORM_1 + 1;
end else
begin
for i := IMG_TAB_NORM_4 downto senderTab do
begin
if (isLeftTab[i]) then
for j := 1 to 39 do
begin
tImages[i].Left := tImages[i].Left + 10;
Wait(1);
end;

isLeftTab[i] := False;
end;
CurrentPanel := sendertab - IMG_TAB_NORM_1;
end;

for i := PANEL_1 to PANEL_5 do
begin
if i = CurrentPanel then
isActivePanel[i] := True
else
isActivePanel[i] := False;
end;

WriteLn(CurrentPanel);

for i := IMG_LOC_ICON_NORM to IMG_TAB_HINT do
tImages[i].Visible := isActivePanel[PANEL_1];
{for i := Timagesblah to blah do
tImages[i].Visible := isActivePanel[PANEL_2];
for i := Timagesblah to blah do
tImages[i].Visible := isActivePanel[PANEL_3];
for i := Timagesblah to blah do
tImages[i].Visible := isActivePanel[PANEL_4];
for i := Timagesblah to blah do
tImages[i].Visible := isActivePanel[PANEL_5]; }

end;

procedure LocViewer(Sender: TObject);
var i: Integer;
begin
case Sender of
tImages[IMG_LOC_ICON_NORM]:
begin
for i := IMG_LOC_MAP to IMG_LOC_BOX_BOTTOM do
tImages[i].Visible := True;
for i := IMG_LOC_ICON_NORM to IMG_TAB_HINT do
tImages[i].Visible := False;
end;

tImages[IMG_LOC_EXIT_NORM]:
begin
for i := IMG_LOC_MAP to IMG_LOC_BOX_BOTTOM do
tImages[i].Visible := False;
for i := IMG_LOC_ICON_NORM to IMG_TAB_HINT do
tImages[i].Visible := isActivePanel[PANEL_1];
end;
end;
end;

procedure Clicked(Sender: TObject);
var
i: Integer;
begin
for i := 0 to BITMAP_COUNT - 1 do
FreeBitmap(frmBitmaps[i]);
frmMain.ModalResult := mrOk;
end;

procedure MouseMoved(Sender: TObject; Shift: TShiftState; x, y: Integer);
var
hi, i, bmp: Integer;
imgSwap, bmpArr, imgArr: Array of Integer;
begin
case Sender of
tImages[IMG_BGND], tImages[IMG_LOC_MAP]:
begin
bmpArr := [ X_NORM, Q_NORM, LOAD_TAB_NORM,
SAVE_TAB_NORM, TAB_NORM_1, TAB_NORM_2,
TAB_NORM_3, TAB_NORM_4, LOC_ICON_NORM, LOC_EXIT_NORM ]

imgArr := [ IMG_X_NORM, IMG_Q_NORM, IMG_LOAD_TAB_NORM,
IMG_SAVE_TAB_NORM, IMG_TAB_NORM_1, IMG_TAB_NORM_2,
IMG_TAB_NORM_3, IMG_TAB_NORM_4, IMG_LOC_ICON_NORM, IMG_LOC_EXIT_NORM ]

hi := High(bmpArr);
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;

bmp := frmBitmaps[bmpArr[i]];
DrawBitmap(bmp,tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;

tImages[IMG_X_NORM], tImages[IMG_Q_NORM], tImages[IMG_LOAD_TAB_NORM], tImages[IMG_SAVE_TAB_NORM],
tImages[IMG_TAB_NORM_1], tImages[IMG_TAB_NORM_2], tImages[IMG_TAB_NORM_3], tImages[IMG_TAB_NORM_4],
tImages[IMG_LOC_ICON_NORM], tImages[IMG_LOC_EXIT_NORM]:

begin
case Sender of
tImages[IMG_X_NORM]:
imgSwap := [IMG_X_NORM, frmBitmaps[X_HOVER]];

tImages[IMG_Q_NORM]:
imgSwap := [IMG_Q_NORM, frmBitmaps[Q_HOVER]];

tImages[IMG_LOAD_TAB_NORM]:
imgSwap := [IMG_LOAD_TAB_NORM, frmBitmaps[LOAD_TAB_HOVER]];

tImages[IMG_SAVE_TAB_NORM]:
imgSwap := [IMG_SAVE_TAB_NORM, frmBitmaps[SAVE_TAB_HOVER]];

tImages[IMG_TAB_NORM_1]:
imgSwap := [IMG_TAB_NORM_1, frmBitmaps[TAB_HOVER_1]];

tImages[IMG_TAB_NORM_2]:
imgSwap := [IMG_TAB_NORM_2, frmBitmaps[TAB_HOVER_2]];

tImages[IMG_TAB_NORM_3]:
imgSwap := [IMG_TAB_NORM_3, frmBitmaps[TAB_HOVER_3]];

tImages[IMG_TAB_NORM_4]:
imgSwap := [IMG_TAB_NORM_4, frmBitmaps[TAB_HOVER_4]];

tImages[IMG_LOC_ICON_NORM]:
imgSwap := [IMG_LOC_ICON_NORM, frmBitmaps[LOC_ICON_HOVER]];

tImages[IMG_LOC_EXIT_NORM]:
imgSwap := [IMG_LOC_EXIT_NORM, frmBitmaps[LOC_EXIT_HOVER]];
end;

if (isActiveImage[imgSwap[0]]) then
Exit;

DrawBitmap(imgSwap[1],tImages[imgSwap[0]].Canvas,0,0);
isActiveImage[imgSwap[0]] := True;



bmpArr := [ X_NORM, Q_NORM, LOAD_TAB_NORM,
SAVE_TAB_NORM, TAB_NORM_1, TAB_NORM_2,
TAB_NORM_3, TAB_NORM_4, LOC_ICON_NORM, LOC_EXIT_NORM ]

imgArr := [ IMG_X_NORM, IMG_Q_NORM, IMG_LOAD_TAB_NORM,
IMG_SAVE_TAB_NORM, IMG_TAB_NORM_1, IMG_TAB_NORM_2,
IMG_TAB_NORM_3, IMG_TAB_NORM_4, IMG_LOC_ICON_NORM, IMG_LOC_EXIT_NORM ]

hi := High(bmpArr);
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;

if (i = imgSwap[0] - 1) or (i = imgSwap[0] - 2) or (i = imgSwap[0] - 12) then // Must be chaged if orders are chaNged
Continue;

bmp := frmBitmaps[bmpArr[i]];
DrawBitmap(bmp,tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;

end;
end;
end;

procedure InitForm;
var
Image, bmp: Integer;
hi, i: Integer;
bmpArr: Array [0..BITMAP_COUNT - 1] of String;
begin

bmpArr[BGND] := 'BGND.png';
bmpArr[X_NORM] := 'X_NORM.png';
bmpArr[X_HOVER] := 'X_HOVER.png';
bmpArr[Q_NORM] := 'Q_NORM.png';
bmpArr[Q_HOVER] := 'Q_HOVER.png';
bmpArr[LOAD_TAB_NORM] := 'LOAD_TAB_NORM.png';
bmpArr[LOAD_TAB_HOVER] := 'LOAD_TAB_HOVER.png';
bmpArr[SAVE_TAB_NORM] := 'SAVE_TAB_NORM.png';
bmpArr[SAVE_TAB_HOVER] := 'SAVE_TAB_HOVER.png';

bmpArr[TAB_NORM_1] := 'TAB_NORM_1.png';
bmpArr[TAB_NORM_2] := 'TAB_NORM_2.png';
bmpArr[TAB_NORM_3] := 'TAB_NORM_3.png';
bmpArr[TAB_NORM_4] := 'TAB_NORM_4.png';
bmpArr[TAB_HOVER_1] := 'TAB_HOVER_1.png';
bmpArr[TAB_HOVER_2] := 'TAB_HOVER_2.png';
bmpArr[TAB_HOVER_3] := 'TAB_HOVER_3.png';
bmpArr[TAB_HOVER_4] := 'TAB_HOVER_4.png';

bmpArr[LOC_ICON_NORM] := 'LOC_ICON_NORM.png';
bmpArr[LOC_ICON_HOVER] := 'LOC_ICON_HOVER.png';

bmpArr[LOC_MAP] := 'LOC_MAP.png';
bmpArr[LOC_NAV] := 'LOC_NAV.png';
bmpArr[LOC_EXIT_NORM] := 'LOC_EXIT_NORM.png';
bmpArr[LOC_EXIT_HOVER] := 'LOC_EXIT_HOVER.png';
bmpArr[LOC_BORD_TOP] := 'LOC_BORD_TOP.png';
bmpArr[LOC_BORD_BOTTOM] := 'LOC_BORD_BOTTOM.png';
bmpArr[LOC_BORD_LEFT] := 'LOC_BORD_LEFT.png';
bmpArr[LOC_BORD_RIGHT] := 'LOC_BORD_RIGHT.png';
bmpArr[LOC_BOX_TOP] := 'LOC_BOX_TOP.png';
bmpArr[LOC_BOX_LEFT] := 'LOC_BOX_LEFT.png';

bmpArr[LOC_LABEL] := 'LOC_LABEL.png';
bmpArr[TAB_HINT] := 'TAB_HINT.png';



hi := High(frmBitmaps);
for i := 0 to hi do
frmBitmaps[i] := LoadBitmap(ScriptPath + 'Bitmaps\' + bmpArr[i]);

{
MAIN FORM
}

frmMain := TForm.Create(nil);
with frmMain do
begin
SetBounds({L} 100, {T} 100, {W} 600, {H} 400);
//Position := poScreenCenter;
//Width := 600;
//Height := 400;
BorderStyle := bsNone;
end;

for Image := 0 to IMG_TAB_HINT do
begin
tImages[Image] := TImage.Create(frmMain);
with tImages[Image] do
begin
Parent := frmMain;
case Image of
IMG_BGND:
begin
SetBounds({L} 0, {T} 0, {W} 600, {H} 400);
bmp := frmBitmaps[BGND];
OnMouseMove := @MouseMoved;
isActiveImage[BGND] := False;
end;

IMG_X_NORM:
begin
SetBounds({L} 575, {T} 7, {W} 18, {H} 18);
bmp := frmBitmaps[X_NORM];
OnClick := @Clicked;
OnMouseMove := @MouseMoved;
isActiveImage[IMG_X_NORM] := False;
end;

IMG_Q_NORM:
begin
SetBounds({L} 557, {T} 7, {W} 18, {H} 18);
bmp := frmBitmaps[Q_NORM];
OnMouseMove := @MouseMoved;
isActiveImage[IMG_Q_NORM] := False;
end;

IMG_LOAD_TAB_NORM:
begin
SetBounds({L} 7, {T} 69, {W} 74, {H} 22);
bmp := frmBitmaps[LOAD_TAB_NORM];
OnMouseMove := @MouseMoved;
isActiveImage[IMG_LOAD_TAB_NORM] := False;
end;

IMG_SAVE_TAB_NORM:
begin
SetBounds({L} 81, {T} 69, {W} 74, {H} 22);
bmp := frmBitmaps[SAVE_TAB_NORM];
OnMouseMove := @MouseMoved;
isActiveImage[IMG_SAVE_TAB_NORM] := False;
end;

IMG_TAB_NORM_1:
begin
SetBounds({L} 390, {T} 99, {W} 50, {H} 290);
bmp := frmBitmaps[TAB_NORM_1];
OnMouseMove := @MouseMoved;
OnClick := @TabClick;
isActiveImage[IMG_TAB_NORM_1] := False;
isLeftTab[IMG_TAB_NORM_1] := False;
end;

IMG_TAB_NORM_2:
begin
SetBounds({L} 440, {T} 99, {W} 50, {H} 290);
bmp := frmBitmaps[TAB_NORM_2];
OnMouseMove := @MouseMoved;
OnClick := @TabClick;
isActiveImage[IMG_TAB_NORM_2] := False;
isLeftTab[IMG_TAB_NORM_1] := False;
end;

IMG_TAB_NORM_3:
begin
SetBounds({L} 490, {T} 99, {W} 50, {H} 290);
bmp := frmBitmaps[TAB_NORM_3];
OnMouseMove := @MouseMoved;
OnClick := @TabClick;
isActiveImage[BGND] := False;
isLeftTab[IMG_TAB_NORM_1] := False;
end;

IMG_TAB_NORM_4:
begin
SetBounds({L} 540, {T} 99, {W} 50, {H} 290);
bmp := frmBitmaps[TAB_NORM_4];
OnMouseMove := @MouseMoved;
OnClick := @TabClick;
isActiveImage[IMG_TAB_NORM_4] := False;
isLeftTab[IMG_TAB_NORM_1] := False;
end;

IMG_LOC_ICON_NORM:
begin
SetBounds({L} 179, {T} 204, {W} 40, {H} 41);
bmp := frmBitmaps[LOC_ICON_NORM];
OnClick := @LocViewer;
OnMouseMove := @MouseMoved;
isActiveImage[IMG_LOC_ICON_NORM] := False;
end;


// Location Viewer

IMG_LOC_MAP:
begin
SetBounds({L} -300, {T} 0, {W} 945, {H} 754);
bmp := frmBitmaps[LOC_MAP];
ONMOUSEDOWN := @OnMouseDown;
//OnMouseMove := @MouseMoved;
OnMouseMove := @OnMouseMove;
isActiveImage[IMG_LOC_MAP] := False;
Visible := False;
end;

IMG_LOC_NAV:
begin
SetBounds({L} 369, {T} 209, {W} 215, {H} 175);
bmp := frmBitmaps[LOC_NAV];
OnClick := @Navigator;
OnMouseMove := @MouseMoved;
isActiveImage[IMG_LOC_NAV] := False;
Visible := False;
end;

IMG_LOC_EXIT_NORM:
begin
SetBounds({L} 475, {T} 7, {W} 119, {H} 22);
bmp := frmBitmaps[LOC_EXIT_NORM];
OnClick := @LocViewer;
OnMouseMove := @MouseMoved;
isActiveImage[IMG_LOC_MAP] := False;
Visible := False;
end;

IMG_LOC_BORD_TOP:
begin
SetBounds({L} 0, {T} 0, {W} 600, {H} 7);
bmp := frmBitmaps[LOC_BORD_TOP];
isActiveImage[IMG_LOC_BORD_TOP] := False;
Visible := False;
end;

IMG_LOC_BORD_BOTTOM:
begin
SetBounds({L} 0, {T} 393, {W} 600, {H} 7);
bmp := frmBitmaps[LOC_BORD_BOTTOM];
isActiveImage[IMG_LOC_BORD_BOTTOM] := False;
Visible := False;
end;

IMG_LOC_BORD_LEFT:
begin
SetBounds({L} 0, {T} 7, {W} 7, {H} 386);
bmp := frmBitmaps[LOC_BORD_LEFT];
isActiveImage[IMG_LOC_BORD_LEFT] := False;
Visible := False;
end;

IMG_LOC_BORD_RIGHT:
begin
SetBounds({L} 593, {T} 7, {W} 7, {H} 386);
bmp := frmBitmaps[LOC_BORD_RIGHT];
isActiveImage[IMG_LOC_BORD_RIGHT] := False;
Visible := False;
end;

IMG_LOC_BOX_TOP:
begin
SetBounds({L} -tImages[IMG_LOC_MAP].Left / 4 + 376, {T} -tImages[IMG_LOC_MAP].Top / 4 + 216, {W} 110, {H} 1);
bmp := frmBitmaps[LOC_BOX_TOP];
isActiveImage[IMG_LOC_BOX_TOP] := False;
Visible := False;
end;

IMG_LOC_BOX_LEFT:
begin
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 80);
bmp := frmBitmaps[LOC_BOX_LEFT];
isActiveImage[IMG_LOC_BOX_LEFT] := False;
Visible := False;
end;

IMG_LOC_BOX_RIGHT:
begin
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 109, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 80);
bmp := frmBitmaps[LOC_BOX_LEFT];
isActiveImage[IMG_LOC_BOX_RIGHT] := False;
Visible := False;
end;

IMG_LOC_BOX_BOTTOM:
begin
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 80, {W} 110, {H} 1);
bmp := frmBitmaps[LOC_BOX_TOP];
isActiveImage[IMG_LOC_BOX_BOTTOM] := False;
Visible := False;
end;

IMG_LOC_LABEL:
begin
SetBounds({L} 156, {T} 250, {W} 87, {H} 11);
bmp := frmBitmaps[LOC_LABEL];
isActiveImage[IMG_LOC_LABEL] := False;
Visible := True;
end;

IMG_TAB_HINT:
begin
SetBounds({L} 208, {T} 379, {W} 174, {H} 10);
bmp := frmBitmaps[TAB_HINT];
isActiveImage[IMG_TAB_HINT] := False;
Visible := True;
end;

end;
end;
DrawBitmap(bmp, tImages[Image].canvas, 0, 0);
end;

isActivePanel[Panel_1] := True;
isActivePanel[Panel_2] := False;
isActivePanel[Panel_3] := False;
isActivePanel[Panel_4] := False;
isActivePanel[Panel_5] := False;


end;

procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;

procedure ShowFormModal;
begin
frmMain.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;

begin
SafeInitForm;
SafeShowFormModal;
end.

Gu3st...

2010-06-25 11:45:22

From: MylesMadness
1. Sorry about deleting that post, completely forgot I had posted that before.
2.
That is awesome! :)
I'm going to have to look at your code to figure out how you did that…

EDIT: Nice :)

Coh3n

2010-06-25 11:46:19

Nice that's exactly what I was talking about. :) Except it flickers like crazy. Oh and the "Exit Location Viewer" image doesn't change back to the unhovered version after you take the mouse off it.

MylesMadness

2010-06-25 11:48:14

It doesn't flicker at all for me…

Coh3n

2010-06-25 11:49:46

From: MylesMadness
It doesn't flicker at all for me…

Yeah I just talked to Zytex. It works fine for him too. It may be just because I'm running Simba with WINE. I'll try in a virtual machine later (I'm still working on switching to script based). I'll just trust you guys that it works. :p

Gu3st...

2010-06-25 11:50:46

Just noticed something… Try clicking at a place (Click, don't Hold the button.) and then move the cursor

Coh3n

2010-06-25 11:53:07

From: Zyt3x
Just noticed something… Try clicking at a place (Click, don't Hold the button.) and then move the cursor

Nothing happens for me…

MylesMadness

2010-06-25 11:53:30

Hes saying on the minimap thing, and that is weird…

Coh3n

2010-06-25 11:56:19

From: MylesMadness
Hes saying on the minimap thing, and that is weird…

Again, nothing weird happens, it just goes to that place on the map.

ReadySteadyGo

2010-06-25 11:57:41

Nice!!!

committed

MylesMadness

2010-06-25 12:02:16

From: Coh3n
Again, nothing weird happens, it just goes to that place on the map.
Click on the minimap, release, then move the mouse off the minimap

Coh3n

2010-06-25 12:04:43

From: MylesMadness
Click on the minimap, release, then move the mouse off the minimap

Ohh I see. That only happens if you move the mouse fast thought. If you click, then wait like a second, it's fine. But either way that shouldn't happen.

ReadySteadyGo

2010-06-25 12:18:37

I've added panning to the navigator.

Coh3n

2010-06-25 12:24:17

From: ReadySteadyGo
I've added panning to the navigator.

Looks good. Still flashes for me, but I'll figure that out later. Also, the "Exit Location Viewer" button image doesn't change back to the unhovered version when you take the mouse off it.

ReadySteadyGo

2010-06-25 12:31:16

From: Coh3n
Looks good. Still flashes for me, but I'll figure that out later. Also, the "Exit Location Viewer" button image doesn't change back to the unhovered version when you take the mouse off it.


fixed.

Coh3n

2010-06-25 12:32:17

Awesome! You guys are doing an awesome job with this. I'm very impressed. :D

ReadySteadyGo

2010-06-26 13:21:42


I suck at icon design, can someone else try?

Coh3n

2010-06-26 13:22:45

I think it looks good, just make it (and the arrow) smaller.

Dynamite

2010-06-26 13:24:24

/me Lieks

MylesMadness

2010-06-26 13:34:09

I think the tree green is a little to bright, but besides that thats quite awesome

Frement

2010-06-26 13:56:43

Heres something I made fast:

Coh3n

2010-06-26 15:55:31

Frement, I think that small one is perfect. :) Maybe make it glow a little or something so it really stands out compared to Jagex's minimap icons? Or, if there's a map out there without the symbols, even better. :D

Gu3st...

2010-06-26 15:58:37

Oh, and sharpen the tree a bit in the small one :)

Frement

2010-06-26 16:11:01

From: Zyt3x
Oh, and sharpen the tree a bit in the small one :)


It cant be much sharpened as the edges are so small.

From: Coh3n
Frement, I think that small one is perfect. :) Maybe make it glow a little or something so it really stands out compared to Jagex's minimap icons? Or, if there's a map out there without the symbols, even better. :D


ReadySteadyGo can add the glow to it when adding to the final map.

ReadySteadyGo

2010-06-26 17:25:06

That's perfect! Nice one Frement. I managed to make a sharper small one by resizing the big one with 'bicubic sharper' resampling. :)

Gu3st...

2010-06-26 17:52:48

From: Frement
It cant be much sharpened as the edges are so small.
Try using something else than Photoshop ;)
Paint for example

EDIT:

marpis

2010-06-26 18:11:50

Remember to keep the icons big enough to be noticed at first sight.
Also a colored blurred shadow behind the arrow and the icon could be nice, to make them more noticeable. :)

You guys should be given a medal of somekind.

Hint, maybe you will ;)

EDIT: I love the form btw :) but it flickers to me too?

i luffs yeww

2010-06-26 20:11:15

Also, I think that the icons should be shown in the small minimap as well. Even if they lap over or something, they can get a general idea of where it is.

:)

Dan Cardin

2010-06-26 22:17:01



you might want to pixel art it rather than compressing larger images.

Wizzup?

2010-06-27 05:12:53

From: Dan Cardin


you might want to pixel art it rather than compressing larger images.


May I suggest using Inkscape when making it yourself? ( http://inkscape.org/?lang=en&css=css/base.css )

Coh3n

2010-06-27 10:18:32

From: marpis
EDIT: I love the form btw :) but it flickers to me too?

At least I'm not the only one. :rolleyes: Are you using Ubuntu also?

Sir R. M8gic1an

2010-06-27 10:20:43

Id suggest making the border of the image a different color. As in yellow-ish / goldish, to show that a script is available there ;)

Should contrast well on the minimap.

~RM

Dan Cardin

2010-06-27 13:32:05

program MSIForm;

const


PANEL_COUNT = 5;
PANEL_1 = 0;
PANEL_2 = 1;
PANEL_3 = 2;
PANEL_4 = 3;
PANEL_5 = 4;


IMG_COUNT = 23;
// Used in frmMain
IMG_BGND = 0;
IMG_X_NORM = 1;
IMG_Q_NORM = 2;
IMG_LOAD_TAB_NORM = 3;
IMG_SAVE_TAB_NORM = 4;
IMG_TAB_NORM_1 = 5;
IMG_TAB_NORM_2 = 6;
IMG_TAB_NORM_3 = 7;
IMG_TAB_NORM_4 = 8;

IMG_LOC_MAP = 9;
IMG_LOC_NAV = 10;
IMG_LOC_EXIT_NORM = 11;
IMG_LOC_BORD_TOP = 12;
IMG_LOC_BORD_BOTTOM = 13;
IMG_LOC_BORD_LEFT = 14;
IMG_LOC_BORD_RIGHT = 15;
IMG_LOC_BOX_TOP = 16;
IMG_LOC_BOX_LEFT = 17;
IMG_LOC_BOX_RIGHT = 18;
IMG_LOC_BOX_BOTTOM = 19;

// Used in Panel 0 (Is also used for frmMain)
IMG_LOC_ICON_NORM = 20;
IMG_LOC_LABEL = 21;
IMG_TAB_HINT = 22;

// Used in Panel 1

// Used in Panel 2

// Used in Panel 3

// Used in Panel 4

BITMAP_COUNT = 31;
BGND = 0;
X_NORM = 1;
X_HOVER = 2;
Q_NORM = 3;
Q_HOVER = 4;
LOAD_TAB_NORM = 5;
LOAD_TAB_HOVER = 6;
SAVE_TAB_NORM = 7;
SAVE_TAB_HOVER = 8;
TAB_NORM_1 = 9;
TAB_NORM_2 = 10;
TAB_NORM_3 = 11;
TAB_NORM_4 = 12;
TAB_HOVER_1 = 13;
TAB_HOVER_2 = 14;
TAB_HOVER_3 = 15;
TAB_HOVER_4 = 16;
LOC_ICON_NORM = 17;
LOC_ICON_HOVER = 18;
LOC_MAP = 19;
LOC_NAV = 20;
LOC_EXIT_NORM = 21;
LOC_EXIT_HOVER = 22;
LOC_BORD_TOP = 23;
LOC_BORD_BOTTOM = 24;
LOC_BORD_LEFT = 25;
LOC_BORD_RIGHT = 26;
LOC_BOX_TOP = 27;
LOC_BOX_LEFT = 28;
LOC_LABEL = 29;
TAB_HINT = 30;

var
frmMain: TForm;
time: TTimer;

tImages: Array[0..IMG_COUNT - 1] of TImage;

frmBitmaps: Array [0..BITMAP_COUNT - 1] of Integer;

isActiveImage: Array[0..IMG_COUNT - 1] of Boolean;
isLeftTab: Array[IMG_TAB_NORM_1..IMG_TAB_NORM_4] of Boolean;
isActivePanel: Array[0..PANEL_COUNT - 1] of Boolean;

MapDragStartX, MapDragStartY: Integer;


procedure OnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
BoundL, BoundT: Extended;
begin
case sender of
tImages[IMG_LOC_MAP]:
begin
MapDragStartX := x;
MapDragStartY := y;
end;
tImages[IMG_LOC_NAV]:
begin
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x - 55 - 100, {T} y - 40 - 100, {W} 83, {H} 1);

if tImages[IMG_LOC_BOX_TOP].Left < 376 then
tImages[IMG_LOC_BOX_TOP].Left := 376;
if tImages[IMG_LOC_BOX_TOP].Top < 216 then
tImages[IMG_LOC_BOX_TOP].Top := 216;
if tImages[IMG_LOC_BOX_TOP].Left > 494 then
tImages[IMG_LOC_BOX_TOP].Left := 494;
if tImages[IMG_LOC_BOX_TOP].Top > 322 then
tImages[IMG_LOC_BOX_TOP].Top := 322;

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

if tImages[IMG_LOC_MAP].Left > 0 then
tImages[IMG_LOC_MAP].Left := 0;
if tImages[IMG_LOC_MAP].Top > 0 then
tImages[IMG_LOC_MAP].Top := 0;
if tImages[IMG_LOC_MAP].Left < -345 then
tImages[IMG_LOC_MAP].Left := -345;
if tImages[IMG_LOC_MAP].Top < -354 then
tImages[IMG_LOC_MAP].Top := -354;
end;
end;
end;

var sended: Tobject;
move: integer;
procedure TimerTabClick(Sender: TObject);
var
senderTab, i, j, CurrentPanel: Integer;
begin
for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_4 do
if (Sended = tImages[i]) then
senderTab := i;

if not(isLeftTab[senderTab]) then
begin
for i := IMG_TAB_NORM_1 to senderTab do
begin
if not(isLeftTab[i]) then
begin
tImages[i].Left := tImages[i].Left - 10;
move := move + 1;
end;
if move >= 38 then
begin
isLeftTab[i] := True;
move := 0;
time.ENABLED := false;
end;
end;
CurrentPanel := sendertab - IMG_TAB_NORM_1 + 1;
end else
begin
for i := IMG_TAB_NORM_4 downto senderTab do
begin
if (isLeftTab[i]) then
begin
tImages[i].Left := tImages[i].Left + 10;
move := move + 1;
end;
if move >= 38 then
begin
isLeftTab[i] := false;
time.ENABLED := false;
move := 0;
end;
end;
CurrentPanel := sendertab - IMG_TAB_NORM_1;
end;

for i := PANEL_1 to PANEL_5 do
begin
if i = CurrentPanel then
isActivePanel[i] := True
else
isActivePanel[i] := False;
end;

WriteLn(CurrentPanel);

for i := IMG_LOC_ICON_NORM to IMG_TAB_HINT do
tImages[i].Visible := isActivePanel[PANEL_1];
end;

procedure TabClick(Sender: TObject);
begin
if not time.ENABLED then
begin
time.enabled := not time.enabled;
sended := Sender;
end;
end;

procedure LocViewer(Sender: TObject);
var i: Integer;
begin
case Sender of
tImages[IMG_LOC_ICON_NORM]:
begin
for i := IMG_LOC_MAP to IMG_LOC_BOX_BOTTOM do
tImages[i].Visible := True;
for i := IMG_LOC_ICON_NORM to IMG_TAB_HINT do
tImages[i].Visible := False;
end;

tImages[IMG_LOC_EXIT_NORM]:
begin
for i := IMG_LOC_MAP to IMG_LOC_BOX_BOTTOM do
tImages[i].Visible := False;
for i := IMG_LOC_ICON_NORM to IMG_TAB_HINT do
tImages[i].Visible := isActivePanel[PANEL_1];
end;
end;
end;

procedure Clicked(Sender: TObject);
var
i: Integer;
begin
for i := 0 to BITMAP_COUNT - 1 do
FreeBitmap(frmBitmaps[i]);
frmMain.ModalResult := mrOk;
end;

procedure MouseMoved(Sender: TObject; Shift: TShiftState; x, y: Integer);
var
hi, i, bmp, xdif, ydif: Integer;
BoundL, BoundT: Extended;
imgSwap, bmpArr, imgArr: Array of Integer;
begin
case Sender of
tImages[IMG_BGND], tImages[IMG_LOC_MAP]:
begin
bmpArr := [ X_NORM, Q_NORM, LOAD_TAB_NORM,
SAVE_TAB_NORM, TAB_NORM_1, TAB_NORM_2,
TAB_NORM_3, TAB_NORM_4, LOC_ICON_NORM, LOC_EXIT_NORM ]

imgArr := [ IMG_X_NORM, IMG_Q_NORM, IMG_LOAD_TAB_NORM,
IMG_SAVE_TAB_NORM, IMG_TAB_NORM_1, IMG_TAB_NORM_2,
IMG_TAB_NORM_3, IMG_TAB_NORM_4, IMG_LOC_ICON_NORM, IMG_LOC_EXIT_NORM ]

hi := High(bmpArr);
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;

bmp := frmBitmaps[bmpArr[i]];
DrawBitmap(bmp,tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;

tImages[IMG_X_NORM], tImages[IMG_Q_NORM], tImages[IMG_LOAD_TAB_NORM], tImages[IMG_SAVE_TAB_NORM],
tImages[IMG_TAB_NORM_1], tImages[IMG_TAB_NORM_2], tImages[IMG_TAB_NORM_3], tImages[IMG_TAB_NORM_4],
tImages[IMG_LOC_ICON_NORM], tImages[IMG_LOC_EXIT_NORM]:

begin
case Sender of
tImages[IMG_X_NORM]:
imgSwap := [IMG_X_NORM, frmBitmaps[X_HOVER]];

tImages[IMG_Q_NORM]:
imgSwap := [IMG_Q_NORM, frmBitmaps[Q_HOVER]];

tImages[IMG_LOAD_TAB_NORM]:
imgSwap := [IMG_LOAD_TAB_NORM, frmBitmaps[LOAD_TAB_HOVER]];

tImages[IMG_SAVE_TAB_NORM]:
imgSwap := [IMG_SAVE_TAB_NORM, frmBitmaps[SAVE_TAB_HOVER]];

tImages[IMG_TAB_NORM_1]:
imgSwap := [IMG_TAB_NORM_1, frmBitmaps[TAB_HOVER_1]];

tImages[IMG_TAB_NORM_2]:
imgSwap := [IMG_TAB_NORM_2, frmBitmaps[TAB_HOVER_2]];

tImages[IMG_TAB_NORM_3]:
imgSwap := [IMG_TAB_NORM_3, frmBitmaps[TAB_HOVER_3]];

tImages[IMG_TAB_NORM_4]:
imgSwap := [IMG_TAB_NORM_4, frmBitmaps[TAB_HOVER_4]];

tImages[IMG_LOC_ICON_NORM]:
imgSwap := [IMG_LOC_ICON_NORM, frmBitmaps[LOC_ICON_HOVER]];

tImages[IMG_LOC_EXIT_NORM]:
imgSwap := [IMG_LOC_EXIT_NORM, frmBitmaps[LOC_EXIT_HOVER]];
end;

if (isActiveImage[imgSwap[0]]) then
Exit;

DrawBitmap(imgSwap[1],tImages[imgSwap[0]].Canvas,0,0);
isActiveImage[imgSwap[0]] := True;



bmpArr := [ X_NORM, Q_NORM, LOAD_TAB_NORM,
SAVE_TAB_NORM, TAB_NORM_1, TAB_NORM_2,
TAB_NORM_3, TAB_NORM_4, LOC_ICON_NORM, LOC_EXIT_NORM ]

imgArr := [ IMG_X_NORM, IMG_Q_NORM, IMG_LOAD_TAB_NORM,
IMG_SAVE_TAB_NORM, IMG_TAB_NORM_1, IMG_TAB_NORM_2,
IMG_TAB_NORM_3, IMG_TAB_NORM_4, IMG_LOC_ICON_NORM, IMG_LOC_EXIT_NORM ]

hi := High(bmpArr);
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;

if (i = imgSwap[0] - 1) then // Must be chaged if orders are chaNged
Continue;
if imgSwap[0] = IMG_LOC_EXIT_NORM then
if (i = imgSwap[0] - 2) then
Continue;
if imgSwap[0] = IMG_LOC_ICON_NORM then
if (i = imgSwap[0] - 12) then
Continue;


bmp := frmBitmaps[bmpArr[i]];
DrawBitmap(bmp,tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;

end;
end;
case sender of
tImages[IMG_LOC_MAP]:
begin
if not IsMouseButtonDown(1) then exit;
xdif := x - MapDragStartX;
ydif := y - MapDragStartY;
{if (xdif < 5) and (ydif < 5) then
begin
GetMousePos(x, y);
tImages[IMG_LOC_MAP].Left := tImages[IMG_LOC_MAP].Left - (x - 300 - 100);
tImages[IMG_LOC_MAP].Top := tImages[IMG_LOC_MAP].Top - (y - 200 - 100);
end else
begin}
tImages[IMG_LOC_MAP].Left := tImages[IMG_LOC_MAP].Left + xdif;
tImages[IMG_LOC_MAP].Top := tImages[IMG_LOC_MAP].Top + ydif;
//end;

if tImages[IMG_LOC_MAP].Left > 0 then
tImages[IMG_LOC_MAP].Left := 0;
if tImages[IMG_LOC_MAP].Top > 0 then
tImages[IMG_LOC_MAP].Top := 0;
if tImages[IMG_LOC_MAP].Left < -854 then
tImages[IMG_LOC_MAP].Left := -854;
if tImages[IMG_LOC_MAP].Top < -765 then
tImages[IMG_LOC_MAP].Top := -765;

{1454 201
1165 161

600 83
400 55

7.234
}

BoundL := -tImages[IMG_LOC_MAP].Left / 7.234 + 376;
BoundT := -tImages[IMG_LOC_MAP].Top / 7.234 + 216;


with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} Round(BoundL), {T} Round(BoundT), {W} 83, {H} 1);

if tImages[IMG_LOC_BOX_TOP].Left < 376 then
tImages[IMG_LOC_BOX_TOP].Left := 376;
if tImages[IMG_LOC_BOX_TOP].Top < 216 then
tImages[IMG_LOC_BOX_TOP].Top := 216;
if tImages[IMG_LOC_BOX_TOP].Left > 494 then
tImages[IMG_LOC_BOX_TOP].Left := 494;
if tImages[IMG_LOC_BOX_TOP].Top > 322 then
tImages[IMG_LOC_BOX_TOP].Top := 322;

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);
end;
tImages[IMG_LOC_NAV]:
begin
if not IsMouseButtonDown(1) then exit;
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x - 55 - 100, {T} y - 40 - 100, {W} 83, {H} 1);

if tImages[IMG_LOC_BOX_TOP].Left < 376 then
tImages[IMG_LOC_BOX_TOP].Left := 376;
if tImages[IMG_LOC_BOX_TOP].Top < 216 then
tImages[IMG_LOC_BOX_TOP].Top := 216;
if tImages[IMG_LOC_BOX_TOP].Left > 494 then
tImages[IMG_LOC_BOX_TOP].Left := 494;
if tImages[IMG_LOC_BOX_TOP].Top > 322 then
tImages[IMG_LOC_BOX_TOP].Top := 322;

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

if tImages[IMG_LOC_MAP].Left > 0 then
tImages[IMG_LOC_MAP].Left := 0;
if tImages[IMG_LOC_MAP].Top > 0 then
tImages[IMG_LOC_MAP].Top := 0;
if tImages[IMG_LOC_MAP].Left < -854 then
tImages[IMG_LOC_MAP].Left := -854;
if tImages[IMG_LOC_MAP].Top < -765 then
tImages[IMG_LOC_MAP].Top := -765;
end;
end;
end;

procedure InitForm;
var
Image, bmp: Integer;
hi, i: Integer;
bmpArr: Array [0..BITMAP_COUNT - 1] of String;
begin

bmpArr[BGND] := 'BGND.png';
bmpArr[X_NORM] := 'X_NORM.png';
bmpArr[X_HOVER] := 'X_HOVER.png';
bmpArr[Q_NORM] := 'Q_NORM.png';
bmpArr[Q_HOVER] := 'Q_HOVER.png';
bmpArr[LOAD_TAB_NORM] := 'LOAD_TAB_NORM.png';
bmpArr[LOAD_TAB_HOVER] := 'LOAD_TAB_HOVER.png';
bmpArr[SAVE_TAB_NORM] := 'SAVE_TAB_NORM.png';
bmpArr[SAVE_TAB_HOVER] := 'SAVE_TAB_HOVER.png';

bmpArr[TAB_NORM_1] := 'TAB_NORM_1.png';
bmpArr[TAB_NORM_2] := 'TAB_NORM_2.png';
bmpArr[TAB_NORM_3] := 'TAB_NORM_3.png';
bmpArr[TAB_NORM_4] := 'TAB_NORM_4.png';
bmpArr[TAB_HOVER_1] := 'TAB_HOVER_1.png';
bmpArr[TAB_HOVER_2] := 'TAB_HOVER_2.png';
bmpArr[TAB_HOVER_3] := 'TAB_HOVER_3.png';
bmpArr[TAB_HOVER_4] := 'TAB_HOVER_4.png';

bmpArr[LOC_ICON_NORM] := 'LOC_ICON_NORM.png';
bmpArr[LOC_ICON_HOVER] := 'LOC_ICON_HOVER.png';

bmpArr[LOC_MAP] := 'LOC_MAP.png';
bmpArr[LOC_NAV] := 'LOC_NAV.png';
bmpArr[LOC_EXIT_NORM] := 'LOC_EXIT_NORM.png';
bmpArr[LOC_EXIT_HOVER] := 'LOC_EXIT_HOVER.png';
bmpArr[LOC_BORD_TOP] := 'LOC_BORD_TOP.png';
bmpArr[LOC_BORD_BOTTOM] := 'LOC_BORD_BOTTOM.png';
bmpArr[LOC_BORD_LEFT] := 'LOC_BORD_LEFT.png';
bmpArr[LOC_BORD_RIGHT] := 'LOC_BORD_RIGHT.png';
bmpArr[LOC_BOX_TOP] := 'LOC_BOX_TOP.png';
bmpArr[LOC_BOX_LEFT] := 'LOC_BOX_LEFT.png';

bmpArr[LOC_LABEL] := 'LOC_LABEL.png';
bmpArr[TAB_HINT] := 'TAB_HINT.png';



hi := High(frmBitmaps);
for i := 0 to hi do
frmBitmaps[i] := LoadBitmap(ScriptPath + 'Bitmaps\' + bmpArr[i]);

{
MAIN FORM
}

frmMain := TForm.Create(nil);
with frmMain do
begin
SetBounds({L} 100, {T} 100, {W} 600, {H} 400);
//Position := poScreenCenter;
//Width := 600;
//Height := 400;
BorderStyle := bsNone;
end;

time := TTimer.Create(frmMain);
time.ONTIMER := @TimerTabClick;
time.INTERVAL := 10;
time.ENABLED := false;

for Image := 0 to IMG_TAB_HINT do
begin
tImages[Image] := TImage.Create(frmMain);
with tImages[Image] do
begin
Parent := frmMain;
case Image of
IMG_BGND:
begin
SetBounds({L} 0, {T} 0, {W} 600, {H} 400);
bmp := frmBitmaps[BGND];
OnMouseMove := @MouseMoved;
isActiveImage[BGND] := False;
end;

IMG_X_NORM:
begin
SetBounds({L} 575, {T} 7, {W} 18, {H} 18);
bmp := frmBitmaps[X_NORM];
OnClick := @Clicked;
OnMouseMove := @MouseMoved;
isActiveImage[IMG_X_NORM] := False;
end;

IMG_Q_NORM:
begin
SetBounds({L} 557, {T} 7, {W} 18, {H} 18);
bmp := frmBitmaps[Q_NORM];
OnMouseMove := @MouseMoved;
isActiveImage[IMG_Q_NORM] := False;
end;

IMG_LOAD_TAB_NORM:
begin
SetBounds({L} 7, {T} 69, {W} 74, {H} 22);
bmp := frmBitmaps[LOAD_TAB_NORM];
OnMouseMove := @MouseMoved;
isActiveImage[IMG_LOAD_TAB_NORM] := False;
end;

IMG_SAVE_TAB_NORM:
begin
SetBounds({L} 81, {T} 69, {W} 74, {H} 22);
bmp := frmBitmaps[SAVE_TAB_NORM];
OnMouseMove := @MouseMoved;
isActiveImage[IMG_SAVE_TAB_NORM] := False;
end;

IMG_TAB_NORM_1:
begin
SetBounds({L} 390, {T} 100, {W} 50, {H} 290);
bmp := frmBitmaps[TAB_NORM_1];
OnMouseMove := @MouseMoved;
OnClick := @TabClick;
isActiveImage[IMG_TAB_NORM_1] := False;
isLeftTab[IMG_TAB_NORM_1] := False;
end;

IMG_TAB_NORM_2:
begin
SetBounds({L} 440, {T} 100, {W} 50, {H} 290);
bmp := frmBitmaps[TAB_NORM_2];
OnMouseMove := @MouseMoved;
OnClick := @TabClick;
isActiveImage[IMG_TAB_NORM_2] := False;
isLeftTab[IMG_TAB_NORM_1] := False;
end;

IMG_TAB_NORM_3:
begin
SetBounds({L} 490, {T} 100, {W} 50, {H} 290);
bmp := frmBitmaps[TAB_NORM_3];
OnMouseMove := @MouseMoved;
OnClick := @TabClick;
isActiveImage[BGND] := False;
isLeftTab[IMG_TAB_NORM_1] := False;
end;

IMG_TAB_NORM_4:
begin
SetBounds({L} 540, {T} 100, {W} 50, {H} 290);
bmp := frmBitmaps[TAB_NORM_4];
OnMouseMove := @MouseMoved;
OnClick := @TabClick;
isActiveImage[IMG_TAB_NORM_4] := False;
isLeftTab[IMG_TAB_NORM_1] := False;
end;

IMG_LOC_ICON_NORM:
begin
SetBounds({L} 179, {T} 204, {W} 40, {H} 41);
bmp := frmBitmaps[LOC_ICON_NORM];
OnClick := @LocViewer;
OnMouseMove := @MouseMoved;
isActiveImage[IMG_LOC_ICON_NORM] := False;
end;


// Location Viewer

IMG_LOC_MAP:
begin
SetBounds({L} -300, {T} 0, {W} 1454, {H} 1165);
bmp := frmBitmaps[LOC_MAP];
ONMOUSEDOWN := @OnMouseDown;
OnMouseMove := @MouseMoved;
isActiveImage[IMG_LOC_MAP] := False;
Visible := False;
end;

IMG_LOC_NAV:
begin
SetBounds({L} 369, {T} 209, {W} 215, {H} 175);
bmp := frmBitmaps[LOC_NAV];
ONMOUSEDOWN := @OnMouseDown;
OnMouseMove := @MouseMoved;
isActiveImage[IMG_LOC_NAV] := False;
Visible := False;
end;

IMG_LOC_EXIT_NORM:
begin
SetBounds({L} 475, {T} 7, {W} 119, {H} 22);
bmp := frmBitmaps[LOC_EXIT_NORM];
OnClick := @LocViewer;
OnMouseMove := @MouseMoved;
isActiveImage[IMG_LOC_MAP] := False;
Visible := False;
end;

IMG_LOC_BORD_TOP:
begin
SetBounds({L} 0, {T} 0, {W} 600, {H} 7);
bmp := frmBitmaps[LOC_BORD_TOP];
isActiveImage[IMG_LOC_BORD_TOP] := False;
Visible := False;
end;

IMG_LOC_BORD_BOTTOM:
begin
SetBounds({L} 0, {T} 393, {W} 600, {H} 7);
bmp := frmBitmaps[LOC_BORD_BOTTOM];
isActiveImage[IMG_LOC_BORD_BOTTOM] := False;
Visible := False;
end;

IMG_LOC_BORD_LEFT:
begin
SetBounds({L} 0, {T} 7, {W} 7, {H} 386);
bmp := frmBitmaps[LOC_BORD_LEFT];
isActiveImage[IMG_LOC_BORD_LEFT] := False;
Visible := False;
end;

IMG_LOC_BORD_RIGHT:
begin
SetBounds({L} 593, {T} 7, {W} 7, {H} 386);
bmp := frmBitmaps[LOC_BORD_RIGHT];
isActiveImage[IMG_LOC_BORD_RIGHT] := False;
Visible := False;
end;

IMG_LOC_BOX_TOP:
begin
SetBounds({L} Round(-tImages[IMG_LOC_MAP].Left / 7.234 + 376), {T} Round(-tImages[IMG_LOC_MAP].Top / 7.234 + 216), {W} 83, {H} 1);
bmp := frmBitmaps[LOC_BOX_TOP];
isActiveImage[IMG_LOC_BOX_TOP] := False;
Visible := False;
end;

IMG_LOC_BOX_LEFT:
begin
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
bmp := frmBitmaps[LOC_BOX_LEFT];
isActiveImage[IMG_LOC_BOX_LEFT] := False;
Visible := False;
end;

IMG_LOC_BOX_RIGHT:
begin
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
bmp := frmBitmaps[LOC_BOX_LEFT];
isActiveImage[IMG_LOC_BOX_RIGHT] := False;
Visible := False;
end;

IMG_LOC_BOX_BOTTOM:
begin
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);
bmp := frmBitmaps[LOC_BOX_TOP];
isActiveImage[IMG_LOC_BOX_BOTTOM] := False;
Visible := False;
end;

IMG_LOC_LABEL:
begin
SetBounds({L} 156, {T} 250, {W} 87, {H} 11);
bmp := frmBitmaps[LOC_LABEL];
isActiveImage[IMG_LOC_LABEL] := False;
Visible := True;
end;

IMG_TAB_HINT:
begin
SetBounds({L} 208, {T} 379, {W} 174, {H} 10);
bmp := frmBitmaps[TAB_HINT];
isActiveImage[IMG_TAB_HINT] := False;
Visible := True;
end;

end;
end;
DrawBitmap(bmp, tImages[Image].canvas, 0, 0);
end;

isActivePanel[Panel_1] := True;
isActivePanel[Panel_2] := False;
isActivePanel[Panel_3] := False;
isActivePanel[Panel_4] := False;
isActivePanel[Panel_5] := False;


end;

procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;

procedure ShowFormModal;
begin
frmMain.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;

begin
SafeInitForm;
SafeShowFormModal;
end.
right there i kind of hacked together a way to animate it moving rather than jumping there. the way you were doing it wouldn't work. It would look nicer with acceleration, but i'd rather not do that until i get clicking ones where multiple ones will move at the same time working.

My first sort of attempt is this
var sended: Tobject;
move: TintegerArray;
procedure TimerTabClick(Sender: TObject);
var
senderTab, i, j, CurrentPanel, h: Integer;
done: boolean;
begin
for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_4 do
if (Sended = tImages[i]) then
senderTab := i;

if not(isLeftTab[senderTab]) then
begin
for i := IMG_TAB_NORM_1 to senderTab do
begin
if not(isLeftTab[i]) then
begin
tImages[i].Left := tImages[i].Left - 10;
move[i] := move[i] + 1;
end;
if move[i] >= 38 then
begin
isLeftTab[i] := True;
move[i] := 0;
done := true;
for h := 0 to high(move) do
if move[h] <> 0 then
done := false;
if done then
time.ENABLED := false;
end;
end;
CurrentPanel := sendertab - IMG_TAB_NORM_1 + 1;
end;{ else
begin
for i := IMG_TAB_NORM_4 downto senderTab do
begin
if (isLeftTab[i]) then
begin
tImages[i].Left := tImages[i].Left + 10;
move := move + 1;
end;
if move >= 38 then
begin
isLeftTab[i] := false;
time.ENABLED := false;
move := 0;
end;
end;
CurrentPanel := sendertab - IMG_TAB_NORM_1;
end; }

for i := PANEL_1 to PANEL_5 do
begin
if i = CurrentPanel then
isActivePanel[i] := True
else
isActivePanel[i] := False;
end;

WriteLn(CurrentPanel);

for i := IMG_LOC_ICON_NORM to IMG_TAB_HINT do
tImages[i].Visible := isActivePanel[PANEL_1];
end;
which i dunno if its going in the right direction. I also think it would be nice to animate the actual tab sliding too (all there is right now would be the location viewer sliding)

Just to say, i think it would make more sense to put the viewer on the player settings tab. Don't you want each player to be able to go somewhere different?

Also, on line 113 of my first code box, i think that should change so that when you click the nav box thing, it keeps the box where it is when you click it. In other words, the cursor should be on the same spot of the box as when you clicked it.

Finally, why do you use all those constants? if you used arrays, you could set all those images (~ line 470) in for loop, and all these
            SetBounds({L} 0, {T} 0, {W} 600, {H} 400);
bmp := frmBitmaps[BGND];
OnMouseMove := @MouseMoved;
isActiveImage[BGND] := False;
in a loop. I guess it makes it more readeable this way, but it also makes it tons longer.

Coh3n

2010-06-27 17:11:01

From: Dan Cardin
Just to say, i think it would make more sense to put the viewer on the player settings tab. Don't you want each player to be able to go somewhere different?

I don't think we're having the user choose which scripts to do on the map, but rather showing the available scripts. They will then go on to choose the scripts in the setup players tab.

From: Dan Cardin

Finally, why do you use all those constants? if you used arrays, you could set all those images (~ line 470) in for loop, and all these
            SetBounds({L} 0, {T} 0, {W} 600, {H} 400);
bmp := frmBitmaps[BGND];
OnMouseMove := @MouseMoved;
isActiveImage[BGND] := False;
in a loop. I guess it makes it more readeable this way, but it also makes it tons longer.

Constants make all the code much more understandable, and how would you load the images in a for loop when they all have different file names?

E: Oh and your scrolling this is awesome. That's originally how I pictured it. However, it's really buggy, but I'm sure you know that. It works getting the tabs there, but trying to bring them back to clicking them out of order, things mess up.

ReadySteadyGo

2010-06-27 17:42:14

Dan:

As Coh3n said, constants are a better way of doing it, and the plan was just to have a viewer. One possible thing is that it could have crops which show in the player set up dynamically (see my design for the panels on the previous page.)

I was thinking of doing the animation with timers, great to see you've started. I can add you to the svn if you want so you can commit? :)

Dan Cardin

2010-06-27 18:29:09

Oh, i was under the impression that the user would click on a skill to do and a route to go by, therein, making a very easy, uncomplicated way of choosing your options.

Coh3n: if you could loop through the bmpArr[]'s then you could just put all the file names in a string array and do it all in one go, like 4 lines in total.
  bmpArr := ['BGND.png','X_NORM.png','X_HOVER.png','Q_NORM.png','Q_HOVER.png','LOAD_TAB_NORM.png','LOAD_TAB_HOVER.png','SAVE_TAB_NORM.png','SAVE_TAB_HOVER.png','TAB_NORM_1.png','TAB_NORM_2.png','TAB_NORM_3.png','TAB_NORM_4.png','TAB_HOVER_1.png','TAB_HOVER_2.png','TAB_HOVER_3.png','TAB_HOVER_4.png','LOC_ICON_NORM.png','LOC_ICON_HOVER.png','LOC_MAP.png','LOC_NAV.png','LOC_EXIT_NORM.png','LOC_EXIT_HOVER.png','LOC_BORD_TOP.png','LOC_BORD_BOTTOM.png','LOC_BORD_LEFT.png','LOC_BORD_RIGHT.png','LOC_BOX_TOP.png','LOC_BOX_LEFT.png','LOC_LABEL.png','TAB_HINT.png'];
hi := High(frmBitmaps);
for i := 0 to hi do
frmBitmaps[i] := LoadBitmap(ScriptPath + 'Bitmaps\' + bmpArr[i]);
and keeping .png in all the images is kind of pointless, not that it particularly matters, just saying.

then at about line 480, you'll do this
  for Image := 0 to IMG_TAB_HINT do
begin
tImages[Image] := TImage.Create(frmMain);
with tImages[Image] do
begin
Parent := frmMain;
xy := [Point(0,0),Point(),Point(),Point(),Point(),Point(),Point(),Point(),Point(),Point(),Point(),Point(),Point(),Point(),
wh := [Point(600,400),Point(),Point(),Point(),Point(),Point(),Point(),Point(),Point(),Point(),Point(),Point(),Point(),Point(),];
visible
for i := 0 to IMG_COUNT do
case Image of
i:
begin
SetBounds(xy[0], xy[1], wh[0], wh[1]);
bmp := frmBitmaps[i];
OnMouseMove := @ProcThatDistributesTheMouseMoveEventsProperly
OnClick := @ProcThatDistributesTheOnClickEventsProperly;
isActiveImage[i] := False;
isLeftTab[IMG_TAB_NORM_1] := lefttabdeterminingVariable ;
visible := VisibleVariable;
end;
makes everything lots shorter, then just next to all of the OnClick events and such, you put a comment saying which one it is, just like you do with {l}, {r}, {w}, and {h}. You can do this all over the place without modifying anything, because all your constants are just 0 to whatever.

ReadySteadyGo

2010-06-27 18:36:35

From: Dan Cardin
Oh, i was under the impression that the user would click on a skill to do and a route to go by, therein, making a very easy, uncomplicated way of choosing your options.


I think that would be very annoying actually, having to navigate the map for each individual player. I like the idea of a dynamic crop so you can do the same thing in one click.

@ your constant objection.
I did that in my first version and it's so much harder to develop around, constants make changing things very simple.

Dan Cardin

2010-06-27 19:24:43

It's the same thing. The only real difference is that you have your "constants" as comments rather than usable words. So whenever you put a 0 instead of the constant name, just comment it in right next to it. For creations and such, or places where you need to do them all at once, it just makes it easier. Adding things in, too, becomes a lot easier. I personally would rather take shorter code instead of overly simplified code, but whatever its not hugely important.

anyways, I got basic-ish acceleration, but my attempts at fixing it so you can click to move more than one at a time keep crashing Simba, so…yeh. You probably don't want me committing, if you'll notice my above posts, its not very organized code.

Sir R. M8gic1an

2010-06-27 20:38:48

using a constant or a 0, in terms of code comes to the same, because const = 0 …

[php]
AXE_BRONZE = 0;
AXE_IRON = 1;
AXE_STEEL = 2;

for i := AXE_BRONZE to AXE_STEEL
writeln(i);
[/php]


0
1
2


~RM

Coh3n

2010-06-27 21:42:32

Also, say you were to use 0 multiple times throughout your script and then for some reason, you needed to change it to another number. With constants, you just change the integer assigned to the constant rather than changing every 0 in your code.

But Dan, the for loops isn't a bad idea (I can't believe I didn't realize that as I use similar code in parts of my form). It really avoids repeating code, but I would probably organize the string array, etc. differently just to make it look neater, but that's just me (and not really a big deal).

marpis

2010-06-28 01:45:23

From: Coh3n
At least I'm not the only one. :rolleyes: Are you using Ubuntu also?


Vista :S

Sir R. M8gic1an

2010-06-28 06:40:37

flickers for me as well.

~RM

Dan Cardin

2010-06-28 20:16:38

i wasn't aware that you could loop through with the constants as well. Well in that case, i suggest doing the string array thing, though i don't know how much more different you'd make it.

My Next version :)
program MSIForm;

const


PANEL_COUNT = 5;
PANEL_1 = 0;
PANEL_2 = 1;
PANEL_3 = 2;
PANEL_4 = 3;
PANEL_5 = 4;


IMG_COUNT = 23;
// Used in frmMain
IMG_BGND = 0;
IMG_X_NORM = 1;
IMG_Q_NORM = 2;
IMG_LOAD_TAB_NORM = 3;
IMG_SAVE_TAB_NORM = 4;
IMG_TAB_NORM_1 = 5;
IMG_TAB_NORM_2 = 6;
IMG_TAB_NORM_3 = 7;
IMG_TAB_NORM_4 = 8;

IMG_LOC_MAP = 9;
IMG_LOC_NAV = 10;
IMG_LOC_EXIT_NORM = 11;
IMG_LOC_BORD_TOP = 12;
IMG_LOC_BORD_BOTTOM = 13;
IMG_LOC_BORD_LEFT = 14;
IMG_LOC_BORD_RIGHT = 15;
IMG_LOC_BOX_TOP = 16;
IMG_LOC_BOX_LEFT = 17;
IMG_LOC_BOX_RIGHT = 18;
IMG_LOC_BOX_BOTTOM = 19;

// Used in Panel 0 (Is also used for frmMain)
IMG_LOC_ICON_NORM = 20;
IMG_LOC_LABEL = 21;
IMG_TAB_HINT = 22;

// Used in Panel 1

// Used in Panel 2

// Used in Panel 3

// Used in Panel 4

BITMAP_COUNT = 31;
BGND = 0;
X_NORM = 1;
X_HOVER = 2;
Q_NORM = 3;
Q_HOVER = 4;
LOAD_TAB_NORM = 5;
LOAD_TAB_HOVER = 6;
SAVE_TAB_NORM = 7;
SAVE_TAB_HOVER = 8;
TAB_NORM_1 = 9;
TAB_NORM_2 = 10;
TAB_NORM_3 = 11;
TAB_NORM_4 = 12;
TAB_HOVER_1 = 13;
TAB_HOVER_2 = 14;
TAB_HOVER_3 = 15;
TAB_HOVER_4 = 16;
LOC_ICON_NORM = 17;
LOC_ICON_HOVER = 18;
LOC_MAP = 19;
LOC_NAV = 20;
LOC_EXIT_NORM = 21;
LOC_EXIT_HOVER = 22;
LOC_BORD_TOP = 23;
LOC_BORD_BOTTOM = 24;
LOC_BORD_LEFT = 25;
LOC_BORD_RIGHT = 26;
LOC_BOX_TOP = 27;
LOC_BOX_LEFT = 28;
LOC_LABEL = 29;
TAB_HINT = 30;

var
frmMain: TForm;
time: TTimer;

tImages: Array[0..IMG_COUNT - 1] of TImage;

frmBitmaps: Array [0..BITMAP_COUNT - 1] of Integer;

isActiveImage: Array[0..IMG_COUNT - 1] of Boolean;
isLeftTab: Array[IMG_TAB_NORM_1..IMG_TAB_NORM_4] of Boolean;
isActivePanel: Array[0..PANEL_COUNT - 1] of Boolean;

MapDragStartX, MapDragStartY: Integer;


procedure OnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
BoundL, BoundT: Extended;
begin
case sender of
tImages[IMG_LOC_MAP]:
begin
MapDragStartX := x;
MapDragStartY := y;
end;
tImages[IMG_LOC_NAV]:
begin
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x + (x - left), {T} y + (y - top), {W} 83, {H} 1);

if tImages[IMG_LOC_BOX_TOP].Left < 376 then
tImages[IMG_LOC_BOX_TOP].Left := 376;
if tImages[IMG_LOC_BOX_TOP].Top < 216 then
tImages[IMG_LOC_BOX_TOP].Top := 216;
if tImages[IMG_LOC_BOX_TOP].Left > 494 then
tImages[IMG_LOC_BOX_TOP].Left := 494;
if tImages[IMG_LOC_BOX_TOP].Top > 322 then
tImages[IMG_LOC_BOX_TOP].Top := 322;

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

if tImages[IMG_LOC_MAP].Left > 0 then
tImages[IMG_LOC_MAP].Left := 0;
if tImages[IMG_LOC_MAP].Top > 0 then
tImages[IMG_LOC_MAP].Top := 0;
if tImages[IMG_LOC_MAP].Left < -345 then
tImages[IMG_LOC_MAP].Left := -345;
if tImages[IMG_LOC_MAP].Top < -354 then
tImages[IMG_LOC_MAP].Top := -354;
end;
end;
end;

var sended: Tobject;
move, accel, cons: integer;
procedure TimerTabClick(Sender: TObject);
var
senderTab, i, CurrentPanel: Integer;
begin
for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_4 do
if (Sended = tImages[i]) then
senderTab := i;

if not(isLeftTab[senderTab]) then
begin
for i := IMG_TAB_NORM_1 to senderTab do
begin
if not(isLeftTab[i]) then
begin
tImages[i].Left := tImages[i].Left - accel;
if move = 0 then
cons := tImages[i].Left;
accel := accel + 2;
move:= move + accel;
end;
if move >= 380 then
begin
tImages[i].Left := cons - 380;
isLeftTab[i] := True;
move := 0;
time.ENABLED := false;
end;
end;
CurrentPanel := sendertab - IMG_TAB_NORM_1 + 1;
end else
begin
for i := IMG_TAB_NORM_4 downto senderTab do
begin
if (isLeftTab[i]) then
begin
tImages[i].Left := tImages[i].Left + accel;
if move = 0 then
cons := tImages[i].Left;
accel := accel + 2;
move := move + accel;
end;
if move >= 380 then
begin
tImages[i].Left := cons + 380;
isLeftTab[i] := False;
move := 0;
time.ENABLED := false;
end;
end;
CurrentPanel := sendertab - IMG_TAB_NORM_1;
end;

for i := PANEL_1 to PANEL_5 do
begin
if i = CurrentPanel then
isActivePanel[i] := True
else
isActivePanel[i] := False;
end;

WriteLn(CurrentPanel);

for i := IMG_LOC_ICON_NORM to IMG_TAB_HINT do
tImages[i].Visible := isActivePanel[PANEL_1];
end;

procedure TabClick(Sender: TObject);
begin
if not time.ENABLED then
begin
accel := 0;
time.enabled := not time.enabled;
sended := Sender;
end;
end;

procedure LocViewer(Sender: TObject);
var i: Integer;
begin
case Sender of
tImages[IMG_LOC_ICON_NORM]:
begin
for i := IMG_LOC_MAP to IMG_LOC_BOX_BOTTOM do
tImages[i].Visible := True;
for i := IMG_LOC_ICON_NORM to IMG_TAB_HINT do
tImages[i].Visible := False;
end;

tImages[IMG_LOC_EXIT_NORM]:
begin
for i := IMG_LOC_MAP to IMG_LOC_BOX_BOTTOM do
tImages[i].Visible := False;
for i := IMG_LOC_ICON_NORM to IMG_TAB_HINT do
tImages[i].Visible := isActivePanel[PANEL_1];
end;
end;
end;

procedure Clicked(Sender: TObject);
var
i: Integer;
begin
for i := 0 to BITMAP_COUNT - 1 do
FreeBitmap(frmBitmaps[i]);
frmMain.ModalResult := mrOk;
end;

procedure MouseMoved(Sender: TObject; Shift: TShiftState; x, y: Integer);
var
hi, i, bmp, xdif, ydif: Integer;
BoundL, BoundT: Extended;
imgSwap, bmpArr, imgArr: Array of Integer;
begin
case Sender of
tImages[IMG_BGND], tImages[IMG_LOC_MAP]:
begin
bmpArr := [ X_NORM, Q_NORM, LOAD_TAB_NORM,
SAVE_TAB_NORM, TAB_NORM_1, TAB_NORM_2,
TAB_NORM_3, TAB_NORM_4, LOC_ICON_NORM, LOC_EXIT_NORM ]

imgArr := [ IMG_X_NORM, IMG_Q_NORM, IMG_LOAD_TAB_NORM,
IMG_SAVE_TAB_NORM, IMG_TAB_NORM_1, IMG_TAB_NORM_2,
IMG_TAB_NORM_3, IMG_TAB_NORM_4, IMG_LOC_ICON_NORM, IMG_LOC_EXIT_NORM ]

hi := High(bmpArr);
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;

bmp := frmBitmaps[bmpArr[i]];
DrawBitmap(bmp,tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;

tImages[IMG_X_NORM], tImages[IMG_Q_NORM], tImages[IMG_LOAD_TAB_NORM], tImages[IMG_SAVE_TAB_NORM],
tImages[IMG_TAB_NORM_1], tImages[IMG_TAB_NORM_2], tImages[IMG_TAB_NORM_3], tImages[IMG_TAB_NORM_4],
tImages[IMG_LOC_ICON_NORM], tImages[IMG_LOC_EXIT_NORM]:

begin ///////////////////////////////10-20
case Sender of
tImages[IMG_X_NORM]:
imgSwap := [IMG_X_NORM, frmBitmaps[X_HOVER]];

tImages[IMG_Q_NORM]:
imgSwap := [IMG_Q_NORM, frmBitmaps[Q_HOVER]];

tImages[IMG_LOAD_TAB_NORM]:
imgSwap := [IMG_LOAD_TAB_NORM, frmBitmaps[LOAD_TAB_HOVER]];

tImages[IMG_SAVE_TAB_NORM]:
imgSwap := [IMG_SAVE_TAB_NORM, frmBitmaps[SAVE_TAB_HOVER]];

tImages[IMG_TAB_NORM_1]:
imgSwap := [IMG_TAB_NORM_1, frmBitmaps[TAB_HOVER_1]];

tImages[IMG_TAB_NORM_2]:
imgSwap := [IMG_TAB_NORM_2, frmBitmaps[TAB_HOVER_2]];

tImages[IMG_TAB_NORM_3]:
imgSwap := [IMG_TAB_NORM_3, frmBitmaps[TAB_HOVER_3]];

tImages[IMG_TAB_NORM_4]:
imgSwap := [IMG_TAB_NORM_4, frmBitmaps[TAB_HOVER_4]];

tImages[IMG_LOC_ICON_NORM]:
imgSwap := [IMG_LOC_ICON_NORM, frmBitmaps[LOC_ICON_HOVER]];

tImages[IMG_LOC_EXIT_NORM]:
imgSwap := [IMG_LOC_EXIT_NORM, frmBitmaps[LOC_EXIT_HOVER]];
end;

if (isActiveImage[imgSwap[0]]) then
Exit;

DrawBitmap(imgSwap[1],tImages[imgSwap[0]].Canvas,0,0);
isActiveImage[imgSwap[0]] := True;



bmpArr := [ X_NORM, Q_NORM, LOAD_TAB_NORM,
SAVE_TAB_NORM, TAB_NORM_1, TAB_NORM_2,
TAB_NORM_3, TAB_NORM_4, LOC_ICON_NORM, LOC_EXIT_NORM ]

imgArr := [ IMG_X_NORM, IMG_Q_NORM, IMG_LOAD_TAB_NORM,
IMG_SAVE_TAB_NORM, IMG_TAB_NORM_1, IMG_TAB_NORM_2,
IMG_TAB_NORM_3, IMG_TAB_NORM_4, IMG_LOC_ICON_NORM, IMG_LOC_EXIT_NORM ]

hi := High(bmpArr);
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;

if (i = imgSwap[0] - 1) then // Must be chaged if orders are chaNged
Continue;
if imgSwap[0] = IMG_LOC_EXIT_NORM then
if (i = imgSwap[0] - 2) then
Continue;
if imgSwap[0] = IMG_LOC_ICON_NORM then
if (i = imgSwap[0] - 12) then
Continue;


bmp := frmBitmaps[bmpArr[i]];
DrawBitmap(bmp,tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;

end;
end;
case sender of
tImages[IMG_LOC_MAP]:
begin
if not IsMouseButtonDown(1) then exit;
xdif := x - MapDragStartX;
ydif := y - MapDragStartY;
{if (xdif < 5) and (ydif < 5) then
begin
GetMousePos(x, y);
tImages[IMG_LOC_MAP].Left := tImages[IMG_LOC_MAP].Left - (x - 300 - 100);
tImages[IMG_LOC_MAP].Top := tImages[IMG_LOC_MAP].Top - (y - 200 - 100);
end else
begin}
tImages[IMG_LOC_MAP].Left := tImages[IMG_LOC_MAP].Left + xdif;
tImages[IMG_LOC_MAP].Top := tImages[IMG_LOC_MAP].Top + ydif;
//end;

if tImages[IMG_LOC_MAP].Left > 0 then
tImages[IMG_LOC_MAP].Left := 0;
if tImages[IMG_LOC_MAP].Top > 0 then
tImages[IMG_LOC_MAP].Top := 0;
if tImages[IMG_LOC_MAP].Left < -854 then
tImages[IMG_LOC_MAP].Left := -854;
if tImages[IMG_LOC_MAP].Top < -765 then
tImages[IMG_LOC_MAP].Top := -765;

{1454 201
1165 161

600 83
400 55

7.234
}

BoundL := -tImages[IMG_LOC_MAP].Left / 7.234 + 376;
BoundT := -tImages[IMG_LOC_MAP].Top / 7.234 + 216;


with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} Round(BoundL), {T} Round(BoundT), {W} 83, {H} 1);

if tImages[IMG_LOC_BOX_TOP].Left < 376 then
tImages[IMG_LOC_BOX_TOP].Left := 376;
if tImages[IMG_LOC_BOX_TOP].Top < 216 then
tImages[IMG_LOC_BOX_TOP].Top := 216;
if tImages[IMG_LOC_BOX_TOP].Left > 494 then
tImages[IMG_LOC_BOX_TOP].Left := 494;
if tImages[IMG_LOC_BOX_TOP].Top > 322 then
tImages[IMG_LOC_BOX_TOP].Top := 322;

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);
end;
tImages[IMG_LOC_NAV]:
begin
if not IsMouseButtonDown(1) then exit;
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x - 55 - 100, {T} y - 40 - 100, {W} 83, {H} 1);

if tImages[IMG_LOC_BOX_TOP].Left < 376 then
tImages[IMG_LOC_BOX_TOP].Left := 376;
if tImages[IMG_LOC_BOX_TOP].Top < 216 then
tImages[IMG_LOC_BOX_TOP].Top := 216;
if tImages[IMG_LOC_BOX_TOP].Left > 494 then
tImages[IMG_LOC_BOX_TOP].Left := 494;
if tImages[IMG_LOC_BOX_TOP].Top > 322 then
tImages[IMG_LOC_BOX_TOP].Top := 322;

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

if tImages[IMG_LOC_MAP].Left > 0 then
tImages[IMG_LOC_MAP].Left := 0;
if tImages[IMG_LOC_MAP].Top > 0 then
tImages[IMG_LOC_MAP].Top := 0;
if tImages[IMG_LOC_MAP].Left < -854 then
tImages[IMG_LOC_MAP].Left := -854;
if tImages[IMG_LOC_MAP].Top < -765 then
tImages[IMG_LOC_MAP].Top := -765;
end;
end;
end;

procedure MouseMoveEvents(Sender: TObject; Shift: TShiftState; x, y: Integer);
begin
{ case sender of
IMG_BGND, IMG_X_NORM, IMG_Q_NORM, IMG_LOAD_TAB_NORM, IMG_SAVE_TAB_NORM, IMG_TAB_NORM_1, IMG_TAB_NORM_2,
IMG_TAB_NORM_3, IMG_TAB_NORM_4, IMG_LOC_ICON_NORM, IMG_LOC_MAP, IMG_LOC_NAV,IMG_LOC_EXIT_NORM: MouseMoved
end; }
end;

procedure OnClickEvents(Sender: TObject);
begin
case Sender of
tImages[IMG_X_NORM]: Clicked(Sender);
tImages[IMG_TAB_NORM_1], tImages[IMG_TAB_NORM_2],tImages[IMG_TAB_NORM_3], tImages[IMG_TAB_NORM_4]: TabClick(Sender);
tImages[IMG_LOC_ICON_NORM], tImages[IMG_LOC_EXIT_NORM]: LocViewer(Sender);
end;
end;

procedure InitForm;
var
Image, bmp: Integer;
hi, i: Integer;
consts: TintegerArray;
bmpArr: TStringArray;
xy, wh: TPointArray;
visibl: TBoolArray;
begin
bmpArr := ['BGND','X_NORM','X_HOVER','Q_NORM','Q_HOVER','LOAD_TAB_NORM','LOAD_TAB_HOVER','SAVE_TAB_NORM','SAVE_TAB_HOVER','TAB_NORM_1','TAB_NORM_2','TAB_NORM_3','TAB_NORM_4','TAB_HOVER_1','TAB_HOVER_2','TAB_HOVER_3','TAB_HOVER_4','LOC_ICON_NORM','LOC_ICON_HOVER','LOC_MAP','LOC_NAV','LOC_EXIT_NORM','LOC_EXIT_HOVER','LOC_BORD_TOP','LOC_BORD_BOTTOM','LOC_BORD_LEFT','LOC_BORD_RIGHT','LOC_BOX_TOP','LOC_BOX_LEFT','LOC_LABEL','TAB_HINT'];
hi := High(frmBitmaps);
for i := 0 to hi do
frmBitmaps[i] := LoadBitmap(ScriptPath + 'Bitmaps\' + bmpArr[i] + '.png');

{
MAIN FORM
}

frmMain := TForm.Create(nil);
with frmMain do
begin
SetBounds({L} 100, {T} 100, {W} 600, {H} 400);
//Position := poScreenCenter;
//Width := 600;
//Height := 400;
BorderStyle := bsNone;
end;

time := TTimer.Create(frmMain);
time.ONTIMER := @TimerTabClick;
time.INTERVAL := 10;
time.ENABLED := false;

xy := [Point(0,0),Point(575,7),Point(557,7),Point(7,69),Point(81,69),Point(390,100),Point(440,100),Point(490,100),Point(540,100),Point(179,204),Point(-300,0),Point(369,209),Point(475,7),Point(0,0), Point(0,393), Point(0,7), Point(593,7), Point(Round( 300 / 7.234 + 376), 216), Point(Round( 300 / 7.234 + 376), 216 + 1), Point(Round( 300 / 7.234 + 376) + 83, 216 + 1), Point(Round( 300 / 7.234 + 376), 216 + 1 + 54), Point(156,250), Point(208,379)];
wh := [Point(600,400),Point(18,18),Point(18,18),Point(74,22),Point(74,22),Point(50,290),Point(50,290),Point(50,290),Point(50,290),Point(40,41),Point(1454,1165),Point(215,175),Point(119,22),Point(600,7),Point(600,7), Point(7,386), Point(7,386), Point(83, 1), Point(1,55), Point(1,55), Point(83,1), Point(87,11), Point(174,10)];
visibl := [true, true,true,true,true, true, true, true,true,true, false, false, false, false, false, false, false, false, false, false, false, true, true];
consts := [BGND,X_NORM,Q_NORM,LOAD_TAB_NORM,SAVE_TAB_NORM,TAB_NORM_1,TAB_NORM_2,TAB_NORM_3,TAB_NORM_4,LOC_ICON_NORM,LOC_MAP,LOC_NAV,LOC_EXIT_NORM ,LOC_BORD_TOP,LOC_BORD_BOTTOM,LOC_BORD_LEFT,LOC_BORD_RIGHT,LOC_BOX_TOP,LOC_BOX_LEFT,LOC_BOX_LEFT,LOC_BOX_TOP,LOC_LABEL,TAB_HINT];
for Image := 0 to IMG_COUNT - 1 do
begin
tImages[Image] := TImage.Create(frmMain);
with tImages[Image] do
begin
Parent := frmMain;
SetBounds(xy[Image].x, xy[Image].y, wh[Image].x, wh[Image].y);
bmp := frmBitmaps[consts[image]];
OnMouseMove := @MouseMoved;
ONMOUSEDOWN := @OnMouseDown;
OnClick := @OnClickEvents;
isActiveImage[Image] := False;
if (Image > IMG_TAB_NORM_1) and (Image < IMG_TAB_NORM_4) then
isLeftTab[Image] := false;
visible := Visibl[Image];
end;
DrawBitmap(bmp, tImages[Image].canvas, 0, 0);
end;

isActivePanel[Panel_1] := True;
isActivePanel[Panel_2] := False;
isActivePanel[Panel_3] := False;
isActivePanel[Panel_4] := False;
isActivePanel[Panel_5] := False;


end;

procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;

procedure ShowFormModal;
begin
frmMain.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;

var finall: integer;
begin
try
SafeInitForm;
SafeShowFormModal;
except
Writeln(ExceptionToString(ExceptionType, ExceptionParam));
end;
end.
i exemplified some of that shortening that I mentioned. Can very likely be done more neatly. It can be done with your imageswap part, but imo, you should reorder the constant's numbers so they form some sort of pattern that you can work from. Such like
BITMAP_COUNT = 31;
BGND = 0;
X_NORM = 1;
X_HOVER = 2;
Q_NORM = 3;
Q_HOVER = 4;
LOAD_TAB_NORM = 5;
LOAD_TAB_HOVER = 6;
SAVE_TAB_NORM = 7;
SAVE_TAB_HOVER = 8;
TAB_NORM_1 = 9;
TAB_HOVER_1 = 10;
TAB_NORM_2 = 11;
TAB_HOVER_2 = 12;
TAB_NORM_3 = 13;
TAB_HOVER_3 = 14;
TAB_NORM_4 = 15;
TAB_HOVER_4 = 16;
LOC_ICON_NORM = 17;
LOC_ICON_HOVER = 18;
LOC_EXIT_NORM = 19;
LOC_EXIT_HOVER = 20;
LOC_MAP = 21;
LOC_NAV = 22;
LOC_BORD_TOP = 23;
LOC_BORD_BOTTOM = 24;
LOC_BORD_LEFT = 25;
LOC_BORD_RIGHT = 26;
LOC_BOX_TOP = 27;
LOC_BOX_LEFT = 28;
LOC_LABEL = 29;
TAB_HINT = 30;
which would make hovering easier to shorten without another array. Also In there, i dont know why you made the 2nd case that's inside the first case. Seems to me that you could just do it in the first case.

EDIT: I seem to have broken the map viewer because it moves the icon and doesn't let you click it, but I'm not sure what I did off the top of my head.

ReadySteadyGo

2010-06-28 20:30:23

What's the point in shortening the code. It makes it harder to read, and harder to update.

But if you do want to take it on, this:

xy := [Point(0,0),Point(575,7),Point(557,7),Point(7,69),Point(81,69),Point(390,100),Point(440,100),Point(490,100),Point(540,100),Point(179,204),Point(-300,0),Point(369,209),Point(475,7),Point(0,0), Point(0,393), Point(0,7), Point(593,7), Point(Round( 300 / 7.234 + 376), 216), Point(Round( 300 / 7.234 + 376), 216 + 1), Point(Round( 300 / 7.234 + 376) + 83, 216 + 1), Point(Round( 300 / 7.234 + 376), 216 + 1 + 54), Point(156,250), Point(208,379)];
wh := [Point(600,400),Point(18,18),Point(18,18),Point(74,22),Point(74,22),Point(50,290),Point(50,290),Point(50,290),Point(50,290),Point(40,41),Point(1454,1165),Point(215,175),Point(119,22),Point(600,7),Point(600,7), Point(7,386), Point(7,386), Point(83, 1), Point(1,55), Point(1,55), Point(83,1), Point(87,11), Point(174,10)];
visibl := [true, true,true,true,true, true, true, true,true,true, false, false, false, false, false, false, false, false, false, false, false, true, true];
consts := [BGND,X_NORM,Q_NORM,LOAD_TAB_NORM,SAVE_TAB_NORM,TAB_NORM_1,TAB_NORM_2,TAB_NORM_3,TAB_NORM_4,LOC_ICON_NORM,LOC_MAP,LOC_NAV,LOC_EXIT_NORM ,LOC_BORD_TOP,LOC_BORD_BOTTOM,LOC_BORD_LEFT,LOC_BORD_RIGHT,LOC_BOX_TOP,LOC_BOX_LEFT,LOC_BOX_LEFT,LOC_BOX_TOP,LOC_LABEL,TAB_HINT];

It would be a lot efficient and readable to make a Type and a function to turn the input into a type. Something like.

LoadImageData(Index, x, y Integer; Visible: Boolean): tImg;

edit: In fact I quite like that, I might implement it if you don't.

+ with regard to the changing of the constants, really easy to do. even more flexible if we implement the Loops.

Sir R. M8gic1an

2010-06-28 20:57:34



tImages[IMG_X_NORM], tImages[IMG_Q_NORM], tImages[IMG_LOAD_TAB_NORM], tImages[IMG_SAVE_TAB_NORM],
tImages[IMG_TAB_NORM_1], tImages[IMG_TAB_NORM_2], tImages[IMG_TAB_NORM_3], tImages[IMG_TAB_NORM_4],
tImages[IMG_LOC_ICON_NORM], tImages[IMG_LOC_EXIT_NORM]:

That's in a case. Isn't it possible to keep some sort of variable with the id of the image, and then just case it as IMG_X_NORM..IMG_LOC_EXIT_NORM ?

if not, how about making some sort of function such as
IsIMGPartOf(Group: integer): boolean;

and just use an if else chain?

~RM

ReadySteadyGo

2010-06-28 21:15:26

That would require completely rearranging the constants and messing it up for when you want to add dynamic panels.

I like the group idea though.

Dan Cardin

2010-06-29 13:41:27

again
program MSIForm;

const


PANEL_COUNT = 5;
PANEL_1 = 0;
PANEL_2 = 1;
PANEL_3 = 2;
PANEL_4 = 3;
PANEL_5 = 4;


IMG_COUNT = 23;
// Used in frmMain
IMG_BGND = 0;
IMG_X_NORM = 1;
IMG_Q_NORM = 2;
IMG_LOAD_TAB_NORM = 3;
IMG_SAVE_TAB_NORM = 4;
IMG_TAB_NORM_1 = 5;
IMG_TAB_NORM_2 = 6;
IMG_TAB_NORM_3 = 7;
IMG_TAB_NORM_4 = 8;

IMG_LOC_MAP = 9;
IMG_LOC_NAV = 10;
IMG_LOC_EXIT_NORM = 11;
IMG_LOC_BORD_TOP = 12;
IMG_LOC_BORD_BOTTOM = 13;
IMG_LOC_BORD_LEFT = 14;
IMG_LOC_BORD_RIGHT = 15;
IMG_LOC_BOX_TOP = 16;
IMG_LOC_BOX_LEFT = 17;
IMG_LOC_BOX_RIGHT = 18;
IMG_LOC_BOX_BOTTOM = 19;

// Used in Panel 0 (Is also used for frmMain)
IMG_LOC_ICON_NORM = 20;
IMG_LOC_LABEL = 21;
IMG_TAB_HINT = 22;

// Used in Panel 1

// Used in Panel 2

// Used in Panel 3

// Used in Panel 4

BITMAP_COUNT = 31;
BGND = 0;
X_NORM = 1;
X_HOVER = 2;
Q_NORM = 3;
Q_HOVER = 4;
LOAD_TAB_NORM = 5;
LOAD_TAB_HOVER = 6;
SAVE_TAB_NORM = 7;
SAVE_TAB_HOVER = 8;
TAB_NORM_1 = 9;
TAB_HOVER_1 = 10;
TAB_NORM_2 = 11;
TAB_HOVER_2 = 12;
TAB_NORM_3 = 13;
TAB_HOVER_3 = 14;
TAB_NORM_4 = 15;
TAB_HOVER_4 = 16;
LOC_ICON_NORM = 17;
LOC_ICON_HOVER = 18;
LOC_EXIT_NORM = 19;
LOC_EXIT_HOVER = 20;
LOC_MAP = 21;
LOC_NAV = 22;
LOC_BORD_TOP = 23;
LOC_BORD_BOTTOM = 24;
LOC_BORD_LEFT = 25;
LOC_BORD_RIGHT = 26;
LOC_BOX_TOP = 27;
LOC_BOX_LEFT = 28;
LOC_LABEL = 29;
TAB_HINT = 30;

var
frmMain: TForm;
time: TTimer;

tImages: Array[0..IMG_COUNT - 1] of TImage;

frmBitmaps: Array [0..BITMAP_COUNT - 1] of Integer;

isActiveImage: Array[0..IMG_COUNT - 1] of Boolean;
isLeftTab: Array[IMG_TAB_NORM_1..IMG_TAB_NORM_4] of Boolean;
isActivePanel: Array[0..PANEL_COUNT - 1] of Boolean;

MapDragStartX, MapDragStartY: Integer;


procedure OutsideBox(l,t,r,b, obj: integer);
begin
if tImages[obj].Left > l then
tImages[obj].Left := l;
if tImages[obj].Top > t then
tImages[obj].Top := t;
if tImages[obj].Left < r then
tImages[obj].Left := r;
if tImages[obj].Top < b then
tImages[obj].Top := b;
end;

procedure OnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
BoundL, BoundT: Extended;
begin
case sender of
tImages[IMG_LOC_MAP]:
begin
MapDragStartX := x;
MapDragStartY := y;
end;
tImages[IMG_LOC_NAV]:
begin
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x + (x - left), {T} y + (y - top), {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

OutsideBox(0,0,-345, -354, IMG_LOC_MAP);
end;
end;
end;

var sended: Tobject;
move, accel, cons: integer;
procedure TimerTabClick(Sender: TObject);
var
senderTab, i, CurrentPanel: Integer;
begin
for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_4 do
if (Sended = tImages[i]) then
senderTab := i;

if not(isLeftTab[senderTab]) then
begin
for i := IMG_TAB_NORM_1 to senderTab do
begin
if not(isLeftTab[i]) then
begin
tImages[i].Left := tImages[i].Left - accel;
if move = 0 then
cons := tImages[i].Left;
accel := accel + 2;
move:= move + accel;
end;
if move >= 380 then
begin
tImages[i].Left := cons - 380;
isLeftTab[i] := True;
move := 0;
time.ENABLED := false;
end;
end;
CurrentPanel := sendertab - IMG_TAB_NORM_1 + 1;
end else
begin
for i := IMG_TAB_NORM_4 downto senderTab do
begin
if (isLeftTab[i]) then
begin
tImages[i].Left := tImages[i].Left + accel;
if move = 0 then
cons := tImages[i].Left;
accel := accel + 2;
move := move + accel;
end;
if move >= 380 then
begin
tImages[i].Left := cons + 380;
isLeftTab[i] := False;
move := 0;
time.ENABLED := false;
end;
end;
CurrentPanel := sendertab - IMG_TAB_NORM_1;
end;

for i := PANEL_1 to PANEL_5 do
begin
if i = CurrentPanel then
isActivePanel[i] := True
else
isActivePanel[i] := False;
end;

//WriteLn(CurrentPanel);

for i := IMG_LOC_ICON_NORM to IMG_TAB_HINT do
tImages[i].Visible := isActivePanel[PANEL_1];
end;

procedure TabClick(Sender: TObject);
begin
if not time.ENABLED then
begin
accel := 0;
time.enabled := not time.enabled;
sended := Sender;
end;
end;

procedure LocViewer(Sender: TObject);
var i: Integer;
begin
case Sender of
tImages[IMG_LOC_ICON_NORM]:
begin
for i := IMG_LOC_MAP to IMG_LOC_BOX_BOTTOM do
tImages[i].Visible := True;
for i := IMG_LOC_ICON_NORM to IMG_TAB_HINT do
tImages[i].Visible := False;
end;

tImages[IMG_LOC_EXIT_NORM]:
begin
for i := IMG_LOC_MAP to IMG_LOC_BOX_BOTTOM do
tImages[i].Visible := False;
for i := IMG_LOC_ICON_NORM to IMG_TAB_HINT do
tImages[i].Visible := isActivePanel[PANEL_1];
end;
end;
end;

procedure Clicked(Sender: TObject);
var
i: Integer;
begin
for i := 0 to BITMAP_COUNT - 1 do
FreeBitmap(frmBitmaps[i]);
frmMain.ModalResult := mrOk;
end;

procedure MouseMoved(Sender: TObject; Shift: TShiftState; x, y: Integer);
var
hi, i, bmp, xdif, ydif, h: Integer;
BoundL, BoundT: Extended;
imgSwap, bmpArr, imgArr: Array of Integer;
begin
bmpArr := [ X_NORM, Q_NORM, LOAD_TAB_NORM,
SAVE_TAB_NORM, TAB_NORM_1, TAB_NORM_2,
TAB_NORM_3, TAB_NORM_4, LOC_ICON_NORM, LOC_EXIT_NORM ]

imgArr := [ IMG_X_NORM, IMG_Q_NORM, IMG_LOAD_TAB_NORM,
IMG_SAVE_TAB_NORM, IMG_TAB_NORM_1, IMG_TAB_NORM_2,
IMG_TAB_NORM_3, IMG_TAB_NORM_4, IMG_LOC_ICON_NORM, IMG_LOC_EXIT_NORM ]
hi := High(bmpArr);
case Sender of
tImages[IMG_BGND], tImages[IMG_LOC_MAP]:
begin
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;

bmp := frmBitmaps[bmpArr[i]];
DrawBitmap(bmp,tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;
end;
for h := 0 to hi do
case Sender of
tImages[imgArr[h]]:
begin
imgSwap := [imgArr[h], frmBitmaps[bmpArr[h] + 1]];
if not (isActiveImage[imgSwap[0]]) then
begin
DrawBitmap(imgSwap[1],tImages[imgSwap[0]].Canvas,0,0);
isActiveImage[imgSwap[0]] := True;
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;
if (i = imgSwap[0] - 1) then
Continue;
if imgSwap[0] = IMG_LOC_EXIT_NORM then
if (i = imgSwap[0] - 2) then
Continue;
if imgSwap[0] = IMG_LOC_ICON_NORM then
if (i = imgSwap[0] - 12) then
Continue;
bmp := frmBitmaps[bmpArr[i]];
DrawBitmap(bmp, tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;
end;
end;
case sender of
tImages[IMG_LOC_MAP]:
begin
if not IsMouseButtonDown(1) then exit;
xdif := x - MapDragStartX;
ydif := y - MapDragStartY;
tImages[IMG_LOC_MAP].Left := tImages[IMG_LOC_MAP].Left + xdif;
tImages[IMG_LOC_MAP].Top := tImages[IMG_LOC_MAP].Top + ydif;

OutsideBox(0,0,-854, -765, IMG_LOC_MAP);

BoundL := -tImages[IMG_LOC_MAP].Left / 7.234 + 376;
BoundT := -tImages[IMG_LOC_MAP].Top / 7.234 + 216;


with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} Round(BoundL), {T} Round(BoundT), {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);
end;
tImages[IMG_LOC_NAV]:
begin
if not IsMouseButtonDown(1) then exit;
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x - 55 - 100, {T} y - 40 - 100, {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

OutsideBox(0, 0, -854, -765, IMG_LOC_MAP);
end;
end;
end;

procedure OnClickEvents(Sender: TObject);
begin
case Sender of
tImages[IMG_X_NORM]: Clicked(Sender);
tImages[IMG_TAB_NORM_1], tImages[IMG_TAB_NORM_2],tImages[IMG_TAB_NORM_3], tImages[IMG_TAB_NORM_4]: TabClick(Sender);
tImages[IMG_LOC_ICON_NORM], tImages[IMG_LOC_EXIT_NORM]: LocViewer(Sender);
end;
end;

procedure InitForm;
var
Image, bmp, hi, i: Integer;
consts: TintegerArray;
bmpArr: TStringArray;
xy, wh: TPointArray;
visibl: TBoolArray;
begin
bmpArr := ['BGND','X_NORM','X_HOVER','Q_NORM','Q_HOVER','LOAD_TAB_NORM','LOAD_TAB_HOVER','SAVE_TAB_NORM','SAVE_TAB_HOVER','TAB_NORM_1','TAB_HOVER_1','TAB_NORM_2','TAB_HOVER_2','TAB_NORM_3','TAB_HOVER_3','TAB_NORM_4','TAB_HOVER_4','LOC_ICON_NORM','LOC_ICON_HOVER','LOC_EXIT_NORM','LOC_EXIT_HOVER','LOC_MAP','LOC_NAV','LOC_BORD_TOP','LOC_BORD_BOTTOM','LOC_BORD_LEFT','LOC_BORD_RIGHT','LOC_BOX_TOP','LOC_BOX_LEFT','LOC_LABEL','TAB_HINT'];
hi := High(frmBitmaps);
for i := 0 to hi do
frmBitmaps[i] := LoadBitmap(ScriptPath + 'Bitmaps\' + bmpArr[i] + '.png');

{
MAIN FORM
}

frmMain := TForm.Create(nil);
with frmMain do
begin
SetBounds({L} 100, {T} 100, {W} 600, {H} 400);
//Position := poScreenCenter;
//Width := 600;
//Height := 400;
BorderStyle := bsNone;
end;

time := TTimer.Create(frmMain);
time.ONTIMER := @TimerTabClick;
time.INTERVAL := 10;
time.ENABLED := false;

xy := [Point(0,0), Point(575,7), Point(557,7), Point(7,69), Point(81,69), Point(390,100), Point(440,100), Point(490,100), Point(540,100), Point(179,204), Point(-300,0), Point(369,209), Point(475,7), Point(0,0), Point(0,393), Point(0,7), Point(593,7), Point(Round( 300 / 7.234 + 376), 216), Point(Round( 300 / 7.234 + 376), 216 + 1), Point(Round( 300 / 7.234 + 376) + 83, 216 + 1), Point(Round( 300 / 7.234 + 376), 216 + 1 + 54), Point(156,250), Point(208,379)];
wh := [Point(600,400), Point(18,18), Point(18,18), Point(74,22), Point(74,22), Point(50,290), Point(50,290), Point(50,290), Point(50,290), Point(40,41), Point(1454,1165), Point(215,175), Point(119,22), Point(600,7), Point(600,7), Point(7,386), Point(7,386), Point(83, 1), Point(1,55), Point(1,55), Point(83,1), Point(87,11), Point(174,10)];
visibl := [true, true, true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, true, true];
consts := [BGND, X_NORM, Q_NORM, LOAD_TAB_NORM,SAVE_TAB_NORM,TAB_NORM_1, TAB_NORM_2, TAB_NORM_3, TAB_NORM_4, LOC_ICON_NORM, LOC_MAP, LOC_NAV, LOC_EXIT_NORM, LOC_BORD_TOP, LOC_BORD_BOTTOM, LOC_BORD_LEFT, LOC_BORD_RIGHT, LOC_BOX_TOP, LOC_BOX_LEFT, LOC_BOX_LEFT, LOC_BOX_TOP, LOC_LABEL, TAB_HINT];
for Image := 0 to IMG_COUNT - 1 do
begin
tImages[Image] := TImage.Create(frmMain);
with tImages[Image] do
begin
Parent := frmMain;
SetBounds(xy[Image].x, xy[Image].y, wh[Image].x, wh[Image].y);
bmp := frmBitmaps[consts[image]];
OnMouseMove := @MouseMoved;
ONMOUSEDOWN := @OnMouseDown;
OnClick := @OnClickEvents;
isActiveImage[Image] := False;
if (Image > IMG_TAB_NORM_1) and (Image < IMG_TAB_NORM_4) then
isLeftTab[Image] := false;
visible := Visibl[Image];
end;
DrawBitmap(bmp, tImages[Image].canvas, 0, 0);
end;

isActivePanel[Panel_1] := True;
for i := 1 to high(IsActivePanel) do
isActivePanel[i] := False;
end;

procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;

procedure ShowFormModal;
begin
frmMain.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;

begin
try
SafeInitForm;
SafeShowFormModal;
except
Writeln(ExceptionToString(ExceptionType, ExceptionParam));
end;
end.
I still don't know what i did to screw up the map viewer, but that seems to be the only problem (not including moving more than 1 panel at a time).

EDIT: and i forget if it works like this, but if it does, then would it not make sense to put all the images of a panel onto another image that you're not drawing, then manipulate the visibility and position of that image to do it to the things on it? I know it works for tpanels at least. It would also make animating the actual contents of the panels very easy.

Gu3st...

2010-06-29 17:04:42

Funny bug here:
How to reproduce: Click tab 1, 2, 3, 4 and then 1

Looks really nice guys :)

Frement

2010-06-29 17:14:13

In my opinion the logo needs some work. Maybe the one who designed it could modify it to fit that?

Coh3n

2010-06-29 19:53:20

From: Dan Cardin

EDIT: and i forget if it works like this, but if it does, then would it not make sense to put all the images of a panel onto another image that you're not drawing, then manipulate the visibility and position of that image to do it to the things on it? I know it works for tpanels at least. It would also make animating the actual contents of the panels very easy.

You mean that all the images for each "slide" should be placed on a panel, then the panels made visible/invisible depending on which one is active? That's how I thought it would be done anyway. If not, that's how it should be done. :p

From: Frement
In my opinion the logo needs some work. Maybe the one who designed it could modify it to fit that?

The logo itself I like, I just think the blending needs a little work. Also, I don't think jimmy_mac is active anymore?

Dan Cardin

2010-06-29 20:48:11

well i fixed that Zyt3x :). But the code seems unnecessarily long. The whole thing is basically done twice to account for both directions at the moment. But why the stupid icon for the map thing moves when you mouse over it eludes me still.
program MSIForm;

const


PANEL_COUNT = 5;
PANEL_1 = 0;
PANEL_2 = 1;
PANEL_3 = 2;
PANEL_4 = 3;
PANEL_5 = 4;


IMG_COUNT = 23;
// Used in frmMain
IMG_BGND = 0;
IMG_X_NORM = 1;
IMG_Q_NORM = 2;
IMG_LOAD_TAB_NORM = 3;
IMG_SAVE_TAB_NORM = 4;
IMG_TAB_NORM_1 = 5;
IMG_TAB_NORM_2 = 6;
IMG_TAB_NORM_3 = 7;
IMG_TAB_NORM_4 = 8;

IMG_LOC_MAP = 9;
IMG_LOC_NAV = 10;
IMG_LOC_EXIT_NORM = 11;
IMG_LOC_BORD_TOP = 12;
IMG_LOC_BORD_BOTTOM = 13;
IMG_LOC_BORD_LEFT = 14;
IMG_LOC_BORD_RIGHT = 15;
IMG_LOC_BOX_TOP = 16;
IMG_LOC_BOX_LEFT = 17;
IMG_LOC_BOX_RIGHT = 18;
IMG_LOC_BOX_BOTTOM = 19;

// Used in Panel 0 (Is also used for frmMain)
IMG_LOC_ICON_NORM = 20;
IMG_LOC_LABEL = 21;
IMG_TAB_HINT = 22;

// Used in Panel 1

// Used in Panel 2

// Used in Panel 3

// Used in Panel 4

BITMAP_COUNT = 31;
BGND = 0;
X_NORM = 1;
X_HOVER = 2;
Q_NORM = 3;
Q_HOVER = 4;
LOAD_TAB_NORM = 5;
LOAD_TAB_HOVER = 6;
SAVE_TAB_NORM = 7;
SAVE_TAB_HOVER = 8;
TAB_NORM_1 = 9;
TAB_HOVER_1 = 10;
TAB_NORM_2 = 11;
TAB_HOVER_2 = 12;
TAB_NORM_3 = 13;
TAB_HOVER_3 = 14;
TAB_NORM_4 = 15;
TAB_HOVER_4 = 16;
LOC_ICON_NORM = 17;
LOC_ICON_HOVER = 18;
LOC_EXIT_NORM = 19;
LOC_EXIT_HOVER = 20;
LOC_MAP = 21;
LOC_NAV = 22;
LOC_BORD_TOP = 23;
LOC_BORD_BOTTOM = 24;
LOC_BORD_LEFT = 25;
LOC_BORD_RIGHT = 26;
LOC_BOX_TOP = 27;
LOC_BOX_LEFT = 28;
LOC_LABEL = 29;
TAB_HINT = 30;

var
frmMain: TForm;
time: TTimer;

tImages: Array[0..IMG_COUNT - 1] of TImage;

frmBitmaps: Array [0..BITMAP_COUNT - 1] of Integer;

isActiveImage: Array[0..IMG_COUNT - 1] of Boolean;
isLeftTab: Array[IMG_TAB_NORM_1..IMG_TAB_NORM_4] of Boolean;
isActivePanel: Array[0..PANEL_COUNT - 1] of Boolean;

MapDragStartX, MapDragStartY: Integer;


procedure OutsideBox(l,t,r,b, obj: integer);
begin
if tImages[obj].Left > l then
tImages[obj].Left := l;
if tImages[obj].Top > t then
tImages[obj].Top := t;
if tImages[obj].Left < r then
tImages[obj].Left := r;
if tImages[obj].Top < b then
tImages[obj].Top := b;
end;

procedure OnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
BoundL, BoundT: Extended;
begin
case sender of
tImages[IMG_LOC_MAP]:
begin
MapDragStartX := x;
MapDragStartY := y;
end;
tImages[IMG_LOC_NAV]:
begin
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x + (x - left), {T} y + (y - top), {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

OutsideBox(0,0,-345, -354, IMG_LOC_MAP);
end;
end;
end;

var sended: Tobject;
accel, move: integer;
{move, }cons: array [0..4] of integer;
procedure TimerTabClick(Sender: TObject);
var
senderTab, i, CurrentPanel, allMove,e, temp: Integer;
begin
for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_4 do
if (Sended = tImages[i]) then
senderTab := i;

if isLeftTab[senderTab] then
begin
for i := IMG_TAB_NORM_4 downto senderTab do
begin
if isLeftTab[i] then
begin
if move = 0 then
for e := 0 to IMG_TAB_NORM_4 - senderTab do
cons[e] := tImages[senderTab + e].Left;
if temp = 0 then
begin
accel := accel + 2;
move := move + accel;
end;
tImages[i].Left := tImages[i].Left + accel;
temp := 1;
end;
end;
if move >= 380 then
begin
for e := 0 to IMG_TAB_NORM_4 - senderTab do
if isLeftTab[senderTab + e] then
begin
tImages[senderTab + e].Left := cons[e] + 380;
isLeftTab[senderTab + e] := false;
end;
move := 0;
time.ENABLED := false;
end;
CurrentPanel := sendertab - IMG_TAB_NORM_1;
end else
begin
for i := IMG_TAB_NORM_1 to senderTab do
begin
if not(isLeftTab[i]) then
begin
if move = 0 then
for e := 0 to senderTab - IMG_TAB_NORM_1 do
cons[e] := tImages[IMG_TAB_NORM_1 + e].Left;
if temp = 0 then
begin
accel := accel + 2;
move := move + accel;
end;
tImages[i].Left := tImages[i].Left - accel;
temp := 1;
end;
end;
if move >= 380 then
begin
for e := 0 to senderTab - IMG_TAB_NORM_1 do
if not isLeftTab[IMG_TAB_NORM_1 + e] then
begin
tImages[IMG_TAB_NORM_1 + e].Left := cons[e] - 380;
isLeftTab[IMG_TAB_NORM_1 + e] := True;
end;
move := 0;
time.ENABLED := false;
end;
CurrentPanel := sendertab - IMG_TAB_NORM_1 + 1;
end;

for i := PANEL_1 to PANEL_5 do
begin
if i = CurrentPanel then
isActivePanel[i] := True
else
isActivePanel[i] := False;
end;

//WriteLn(CurrentPanel);

for i := IMG_LOC_ICON_NORM to IMG_TAB_HINT do
tImages[i].Visible := isActivePanel[PANEL_1];
end;

procedure TabClick(Sender: TObject);
begin
if not time.ENABLED then
begin
accel := 0;
time.enabled := not time.enabled;
sended := Sender;
end;
end;

procedure LocViewer(Sender: TObject);
var i: Integer;
begin
case Sender of
tImages[IMG_LOC_ICON_NORM]:
begin
for i := IMG_LOC_MAP to IMG_LOC_BOX_BOTTOM do
tImages[i].Visible := True;
for i := IMG_LOC_ICON_NORM to IMG_TAB_HINT do
tImages[i].Visible := False;
end;

tImages[IMG_LOC_EXIT_NORM]:
begin
for i := IMG_LOC_MAP to IMG_LOC_BOX_BOTTOM do
tImages[i].Visible := False;
for i := IMG_LOC_ICON_NORM to IMG_TAB_HINT do
tImages[i].Visible := isActivePanel[PANEL_1];
end;
end;
end;

procedure Clicked(Sender: TObject);
var
i: Integer;
begin
for i := 0 to BITMAP_COUNT - 1 do
FreeBitmap(frmBitmaps[i]);
frmMain.ModalResult := mrOk;
end;

procedure MouseMoved(Sender: TObject; Shift: TShiftState; x, y: Integer);
var
hi, i, bmp, xdif, ydif, h: Integer;
BoundL, BoundT: Extended;
imgSwap, bmpArr, imgArr: Array of Integer;
begin
bmpArr := [ X_NORM, Q_NORM, LOAD_TAB_NORM,
SAVE_TAB_NORM, TAB_NORM_1, TAB_NORM_2,
TAB_NORM_3, TAB_NORM_4, LOC_ICON_NORM, LOC_EXIT_NORM ]

imgArr := [ IMG_X_NORM, IMG_Q_NORM, IMG_LOAD_TAB_NORM,
IMG_SAVE_TAB_NORM, IMG_TAB_NORM_1, IMG_TAB_NORM_2,
IMG_TAB_NORM_3, IMG_TAB_NORM_4, IMG_LOC_ICON_NORM, IMG_LOC_EXIT_NORM ]
hi := High(bmpArr);
case Sender of
tImages[IMG_BGND], tImages[IMG_LOC_MAP]:
begin
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;

bmp := frmBitmaps[bmpArr[i]];
DrawBitmap(bmp,tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;
end;
for h := 0 to hi do
case Sender of
tImages[imgArr[h]]:
begin
imgSwap := [imgArr[h], frmBitmaps[bmpArr[h] + 1]];
if not (isActiveImage[imgSwap[0]]) then
begin
DrawBitmap(imgSwap[1],tImages[imgSwap[0]].Canvas,0,0);
isActiveImage[imgSwap[0]] := True;
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;
if (i = imgSwap[0] - 1) then
Continue;
if imgSwap[0] = IMG_LOC_EXIT_NORM then
if (i = imgSwap[0] - 2) then
Continue;
if imgSwap[0] = IMG_LOC_ICON_NORM then
if (i = imgSwap[0] - 12) then
Continue;
bmp := frmBitmaps[bmpArr[i]];
DrawBitmap(bmp, tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;
end;
end;
case sender of
tImages[IMG_LOC_MAP]:
begin
if not IsMouseButtonDown(1) then exit;
xdif := x - MapDragStartX;
ydif := y - MapDragStartY;
tImages[IMG_LOC_MAP].Left := tImages[IMG_LOC_MAP].Left + xdif;
tImages[IMG_LOC_MAP].Top := tImages[IMG_LOC_MAP].Top + ydif;

OutsideBox(0,0,-854, -765, IMG_LOC_MAP);

BoundL := -tImages[IMG_LOC_MAP].Left / 7.234 + 376;
BoundT := -tImages[IMG_LOC_MAP].Top / 7.234 + 216;


with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} Round(BoundL), {T} Round(BoundT), {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);
end;
tImages[IMG_LOC_NAV]:
begin
if not IsMouseButtonDown(1) then exit;
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x - 55 - 100, {T} y - 40 - 100, {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

OutsideBox(0, 0, -854, -765, IMG_LOC_MAP);
end;
end;
end;

procedure OnClickEvents(Sender: TObject);
begin
case Sender of
tImages[IMG_X_NORM]: Clicked(Sender);
tImages[IMG_TAB_NORM_1], tImages[IMG_TAB_NORM_2],tImages[IMG_TAB_NORM_3], tImages[IMG_TAB_NORM_4]: TabClick(Sender);
tImages[IMG_LOC_ICON_NORM], tImages[IMG_LOC_EXIT_NORM]: LocViewer(Sender);
end;
end;

procedure InitForm;
var
Image, bmp, hi, i: Integer;
consts: TintegerArray;
bmpArr: TStringArray;
xy, wh: TPointArray;
visibl: TBoolArray;
begin
bmpArr := ['BGND','X_NORM','X_HOVER','Q_NORM','Q_HOVER','LOAD_TAB_NORM','LOAD_TAB_HOVER','SAVE_TAB_NORM','SAVE_TAB_HOVER','TAB_NORM_1','TAB_HOVER_1','TAB_NORM_2','TAB_HOVER_2','TAB_NORM_3','TAB_HOVER_3','TAB_NORM_4','TAB_HOVER_4','LOC_ICON_NORM','LOC_ICON_HOVER','LOC_EXIT_NORM','LOC_EXIT_HOVER','LOC_MAP','LOC_NAV','LOC_BORD_TOP','LOC_BORD_BOTTOM','LOC_BORD_LEFT','LOC_BORD_RIGHT','LOC_BOX_TOP','LOC_BOX_LEFT','LOC_LABEL','TAB_HINT'];
hi := High(frmBitmaps);
for i := 0 to hi do
frmBitmaps[i] := LoadBitmap(ScriptPath + 'Bitmaps\' + bmpArr[i] + '.png');

{
MAIN FORM
}

frmMain := TForm.Create(nil);
with frmMain do
begin
SetBounds({L} 100, {T} 100, {W} 600, {H} 400);
//Position := poScreenCenter;
//Width := 600;
//Height := 400;
BorderStyle := bsNone;
end;

time := TTimer.Create(frmMain);
time.ONTIMER := @TimerTabClick;
time.INTERVAL := 10;
time.ENABLED := false;

xy := [Point(0,0), Point(575,7), Point(557,7), Point(7,69), Point(81,69), Point(390,100), Point(440,100), Point(490,100), Point(540,100), Point(179,204), Point(-300,0), Point(369,209), Point(475,7), Point(0,0), Point(0,393), Point(0,7), Point(593,7), Point(Round( 300 / 7.234 + 376), 216), Point(Round( 300 / 7.234 + 376), 216 + 1), Point(Round( 300 / 7.234 + 376) + 83, 216 + 1), Point(Round( 300 / 7.234 + 376), 216 + 1 + 54), Point(156,250), Point(208,379)];
wh := [Point(600,400), Point(18,18), Point(18,18), Point(74,22), Point(74,22), Point(50,290), Point(50,290), Point(50,290), Point(50,290), Point(40,41), Point(1454,1165), Point(215,175), Point(119,22), Point(600,7), Point(600,7), Point(7,386), Point(7,386), Point(83, 1), Point(1,55), Point(1,55), Point(83,1), Point(87,11), Point(174,10)];
visibl := [true, true, true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, true, true];
consts := [BGND, X_NORM, Q_NORM, LOAD_TAB_NORM,SAVE_TAB_NORM,TAB_NORM_1, TAB_NORM_2, TAB_NORM_3, TAB_NORM_4, LOC_ICON_NORM, LOC_MAP, LOC_NAV, LOC_EXIT_NORM, LOC_BORD_TOP, LOC_BORD_BOTTOM, LOC_BORD_LEFT, LOC_BORD_RIGHT, LOC_BOX_TOP, LOC_BOX_LEFT, LOC_BOX_LEFT, LOC_BOX_TOP, LOC_LABEL, TAB_HINT];
for Image := 0 to IMG_COUNT - 1 do
begin
tImages[Image] := TImage.Create(frmMain);
with tImages[Image] do
begin
Parent := frmMain;
SetBounds(xy[Image].x, xy[Image].y, wh[Image].x, wh[Image].y);
bmp := frmBitmaps[consts[image]];
OnMouseMove := @MouseMoved;
ONMOUSEDOWN := @OnMouseDown;
OnClick := @OnClickEvents;
isActiveImage[Image] := False;
if (Image > IMG_TAB_NORM_1) and (Image < IMG_TAB_NORM_4) then
isLeftTab[Image] := false;
visible := Visibl[Image];
end;
DrawBitmap(bmp, tImages[Image].canvas, 0, 0);
end;

isActivePanel[Panel_1] := True;
for i := 1 to high(IsActivePanel) do
isActivePanel[i] := False;
end;

procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;

procedure ShowFormModal;
begin
frmMain.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;

begin
try
SafeInitForm;
SafeShowFormModal;
except
Writeln(ExceptionToString(ExceptionType, ExceptionParam));
end;
end.

EDIT: yes, that is what i mean. But they may not even need to be visible/invisible. If i remember correctly, if you make the panel the (either the owner or the parent) then were you to place everything on the panel, the give the panel a width of 0, everything would effectively be invisible. Then you just have to increase the width and move it left when activatin that panel and it will appear to be stretching out from behind the other panels.

Coh3n

2010-06-29 21:58:56

From: Dan Cardin
EDIT: yes, that is what i mean. But they may not even need to be visible/invisible. If i remember correctly, if you make the panel the (either the owner or the parent) then were you to place everything on the panel, the give the panel a width of 0, everything would effectively be invisible. Then you just have to increase the width and move it left when activatin that panel and it will appear to be stretching out from behind the other panels.

Whatever works. It sounds like it should work. :)

Dan Cardin

2010-06-30 10:09:30

The problem I'm having is that when you click on the same tab twice in a row, it goes to two different places even though you're selecting that tab both times. It really should switch to the tab that you click on. Which kind of means that it should never have 0 tabs on the left, or if it can, then you shouldn't be able to get back to it once you're on tabs. If that just means adding another tab that is always on the right, then so be it, but the way it is right now doesnt make sense.

and btw, yes it does work :), but im having some problems with it right now. It's kind of annoying to have to write everything, then copy it over again to work with going the opposite direction, and since it uses for to do and for downto do im not sure it can be shortened unless you make repeat/while loops which might be more annoying than just keeping it as is.

Sir R. M8gic1an

2010-06-30 13:53:46

From: Dan Cardin
It's kind of annoying to have to write everything, then copy it over again to work with going the opposite direction


make a function for it?

~RM

Dan Cardin

2010-06-30 17:44:10

It's either not that simple or I am really dense and just am not making it that simple in my head. This whole thing is the function for it. If you can shorten this to work going both left and right, then bless you. I have attempted it, but it doesn't work correctly at the moment.
var sended: Tobject;
accel, move: integer;
cons: array [0..PANEL_COUNT - 1] of integer;
procedure TimerTabClick(Sender: TObject);
var
senderTab, i, CurrentPanel, e, temp: Integer;
begin
for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_4 do
if (Sended = tImages[i]) then
senderTab := i;

if isLeftTab[senderTab] then
begin
for i := IMG_TAB_NORM_4 downto senderTab do
begin
if isLeftTab[i] then
begin
if move = 0 then
for e := 0 to IMG_TAB_NORM_4 - senderTab do
cons[e] := tImages[senderTab + e].Left;
if temp = 0 then
begin
accel := accel + 2;
move := move + accel;
end;
tImages[i].Left := tImages[i].Left + accel;
temp := temp + 1;
end;
end;
if move >= 380 then
begin
for e := 0 to IMG_TAB_NORM_4 - senderTab do
if isLeftTab[senderTab + e] then
begin
tImages[senderTab + e].Left := cons[e] + 380;
isLeftTab[senderTab + e] := false;
end;
move := 0;
time.ENABLED := false;
end;
CurrentPanel := sendertab - IMG_TAB_NORM_1;
for i := 0 to high(panels) do
if i = currentPanel then
begin
panels[CurrentPanel].left := panels[CurrentPanel].left + accel;
panels[CurrentPanel].width := panels[CurrentPanel].width - accel;
end else
if panels[i].width <> 0 then
begin
panels[i].left := panels[i].left - accel;
panels[i].width := panels[i].width + accel;
end;
end else
begin
for i := IMG_TAB_NORM_1 to senderTab do
begin
if not(isLeftTab[i]) then
begin
if move = 0 then
for e := 0 to senderTab - IMG_TAB_NORM_1 do
cons[e] := tImages[IMG_TAB_NORM_1 + e].Left;
if temp = 0 then
begin
accel := accel + 2;
move := move + accel;
end;
tImages[i].Left := tImages[i].Left - accel;
temp := temp + 1;
end;
end;
if move >= 380 then
begin
for e := 0 to senderTab - IMG_TAB_NORM_1 do
if not isLeftTab[IMG_TAB_NORM_1 + e] then
begin
tImages[IMG_TAB_NORM_1 + e].Left := cons[e] - 380;
isLeftTab[IMG_TAB_NORM_1 + e] := True;
end;
move := 0;
time.ENABLED := false;
end;
CurrentPanel := sendertab - IMG_TAB_NORM_1;
for i := 0 to high(panels) do
if i = currentPanel then
begin
panels[CurrentPanel].left := panels[CurrentPanel].left - accel;
panels[CurrentPanel].width := panels[CurrentPanel].width + accel;
end else
if panels[i].width <> 0 then
begin
panels[i].left := panels[i].left + accel;
panels[i].width := panels[i].width - accel;
end;
end;

for i := PANEL_1 to PANEL_5 do
isActivePanel[i] := i = CurrentPanel;

//WriteLn(CurrentPanel);

for i := IMG_LOC_ICON_NORM to IMG_TAB_HINT do
tImages[i].Visible := isActivePanel[PANEL_1];
end;

Sir R. M8gic1an

2010-06-30 17:56:49

the only difference I see is the signs turning into the opposite one. Therefore:


var
Multiplier: integer;
Right: boolean;
begin
if Right then
Multiplier := 1
else
Multiplier := -1;

//...
tImages[i].Left := tImages[i].Left + (accel*Multiplier)

end;

~RM

Dan Cardin

2010-06-30 18:43:51

signs being opposite, constants being in different places, not isActiveTab and isActiveTab, and for/to/do vs for/downto/do

EDIT: and apparently, we need to free forms/timers, which hasn't been being done.

Sir R. M8gic1an

2010-06-30 19:07:33

From: Dan Cardin
signs being opposite, constants being in different places, not isActiveTab and isActiveTab, and for/to/do vs for/downto/do


tabs:

if not((Right)xor(IsActiveTab)) then

That'll give you the opposite of xor, meaning that if both are true or false that it'll return true.

for to do:

if Right then
i := sendertab
else
i := othertab

repeat
//code
i := i + multiplier
until (i <= sendertab)or(i >= othertab)

And i'm not sure what you mean by the constants being in different places?

Btw, I don't think this is good practice. Sure, more efficient for the scripter, but anyone else who tries to understand this will find themselves with an awful lot of logic to understand.

Comments perhaps?

~RM

Dan Cardin

2010-06-30 19:27:38

var sended: Tobject;
accel, move: integer;
{move, }cons: array [0..4] of integer;
procedure TimerTabClick(Sender: TObject);
var
senderTab, i, CurrentPanel, e, temp, d, top, bottom, diff: Integer;
truth: boolean;
begin
for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_4 do
if (Sended = tImages[i]) then
senderTab := i;

if isLeftTab[senderTab] then
begin
d := 1
top := IMG_TAB_NORM_4
bottom := senderTab
truth := true;
end else
begin
d := -1;
top := senderTab
bottom := IMG_TAB_NORM_1
truth := false;
end;
diff := top - bottom;

for i := top to bottom do
begin
if isLeftTab[i] = truth then
begin
if move = 0 then
for e := 0 to diff do
cons[e] := tImages[senderTab + e].Left;
if temp = 0 then
begin
accel := accel - 2 * d;
move := move + accel;
end;
tImages[i].Left := tImages[i].Left + accel * d;
temp := 1;
end;
end;
if move >= 380 then
begin
for e := 0 to diff do
if isLeftTab[bottom + e] = truth then
begin
tImages[bottom + e].Left := cons[e] + 380 * d;
isLeftTab[bottom + e] := not truth;
end;
move := 0;
time.ENABLED := false;
end;
CurrentPanel := sendertab - IMG_TAB_NORM_1;

for i := PANEL_1 to PANEL_5 do
isActivePanel[i] := i = CurrentPanel;

//WriteLn(CurrentPanel);

for i := IMG_LOC_ICON_NORM to IMG_TAB_HINT do
tImages[i].Visible := isActivePanel[PANEL_1];
end;
i think that should work equivalently minus the for loop which i didnt really understand how you meant with your example. My non working attempts at it, well…havent worked yet, so idk. But then again, now that I think of it, the order might not really matter and my refractorations have just failed somewhere else.

For me at least, especially with this particular part, i think this makes more sense. the first bit shows the that there is a difference later in the code between things. And later blocks of code are just the same thing with slight alterations depending on the situation. Longer code is a lot more to take in, and with all the nested ifs and such that just repeat each other, i think i would find it harder to understand.

Comments i suppose could help, but this kind of thing gets a bit complicated for comments. Along with much of this code it very changy right now, since its all very much incomplete. Comments when a more final version comes out, surely.

EDIT: and someone really might want to commit the form freeing if Wizzup is correct (and i don't see why he wouldn't be).

Coh3n

2010-07-01 06:02:44

From: Dan Cardin
EDIT: and someone really might want to commit the form freeing if Wizzup is correct (and i don't see why he wouldn't be).

You only need to free the form when it's closed, and I've never used timers. Also, I think ReadySteadyGo is the only one with commit access to the form's SVN.

Sir R. M8gic1an

2010-07-01 06:23:35

about the loop:

//this
for i := 0 to High(TPA) do
begin

end;

//is that same as
i := 0
repeat
//...
i := i + 1;
until(i >= High(TPA))

My loop with the multiplier thing overcomes the for..to or for..DownTo problem.

~RM

ReadySteadyGo

2010-07-01 06:41:43

From: Coh3n
You only need to free the form when it's closed, and I've never used timers. Also, I think ReadySteadyGo is the only one with commit access to the form's SVN.


Give me google account names and I'll add you.

Dan: I'm still not liking the way you're loading the images. Really messy. I'll do some work on it later.

Dan Cardin

2010-07-01 17:39:14

You only need to free the form when it's closed, and I've never used timers. Also, I think ReadySteadyGo is the only one with commit access to the form's SVN.
indeed, but as far as I can see, it hasn't been being freed, so that's a problem. And in all of my newer versions, there has been a timer.

My loop with the multiplier thing overcomes the for..to or for..DownTo problem.
as i said, the for loop problem, is a nonissue, i was silly. It still may not work, but its a problem elsewhere. The order doesn't matter in the way that I have it now because the order in which the panels are animated isn't important since they're done as a group.

I'm still not liking the way you're loading the images. Really messy. I'll do some work on it later.
I'm not really sure how you mean. Its the same way that you do it without the unnecessary number of lines.

EDIT: i fixed it, if anyone cares. Now the animation code is all better and nice and short :)

Coh3n

2010-07-01 23:33:05

From: Dan Cardin
EDIT: i fixed it, if anyone cares. Now the animation code is all better and nice and short :)

Awesome! So everything is working as it should? Or are there still a couple bugs? By the way, sorry I haven't been very helpful, I've had a lot of other things to do. I should have a lot of time this weekend to work on all the core issues that have been floating around the forums so once that gets out of the way, I plan on finally thoroughly looking through the form code and properly test so we can work out any bugs. :)

Also, thanks for taking over what ReadySteadyGo started (not exactly sure where he went running off to :rolleyes:).

ReadySteadyGo

2010-07-02 00:00:15

From: Coh3n

Also, thanks for taking over what ReadySteadyGo started (not exactly sure where he went running off to :rolleyes:).


So sorry! This week has been very hectic! Dan's been doing a great job. I'll help him out soon.

Coh3n

2010-07-02 00:01:51

From: ReadySteadyGo
So sorry! This week has been very hectic! Dan's been doing a great job. I'll help him out soon.

No worries. :p I'm just very happy to see that there's not only one person working on this. MSI is a team project after all. :)

Dan Cardin

2010-07-02 11:00:23

Well, now's the time for me to be at least a little embarrassed. It may not be the way that I load the images, but my shortening of that area has been part of the reason why I can't get the location viewer to work correctly (and all this time i've been saying how much easier it is :p). I think it's more likely that I either: have the order wrong somehow, am mixing up the on click events, or the script was hardcoded to work in the order that it was before and after changing that it got screwed up. The last part seems the most likely, but I can't seem to find it.

with my shortening:
program MSIForm;

const


PANEL_COUNT = 5;
PANEL_1 = 0;
PANEL_2 = 1;
PANEL_3 = 2;
PANEL_4 = 3;
PANEL_5 = 4;


IMG_COUNT = 23;
// Used in frmMain
IMG_BGND = 0;
IMG_X_NORM = 1;
IMG_Q_NORM = 2;
IMG_LOAD_TAB_NORM = 3;
IMG_SAVE_TAB_NORM = 4;
IMG_TAB_NORM_1 = 5;
IMG_TAB_NORM_2 = 6;
IMG_TAB_NORM_3 = 7;
IMG_TAB_NORM_4 = 8;

IMG_LOC_ICON_NORM = 9;
IMG_LOC_EXIT_NORM = 10;
IMG_LOC_MAP = 11;
IMG_LOC_NAV = 12;
IMG_LOC_BORD_TOP = 13;
IMG_LOC_BORD_BOTTOM = 14;
IMG_LOC_BORD_LEFT = 15;
IMG_LOC_BORD_RIGHT = 16;
IMG_LOC_BOX_TOP = 17;
IMG_LOC_BOX_LEFT = 18;
IMG_LOC_BOX_RIGHT = 19;
IMG_LOC_BOX_BOTTOM = 20;

// Used in Panel 0 (Is also used for frmMain)
IMG_LOC_LABEL = 21;
IMG_TAB_HINT = 22;

// Used in Panel 1

// Used in Panel 2

// Used in Panel 3

// Used in Panel 4

BITMAP_COUNT = 31;
BGND = 0;
X_NORM = 1;
X_HOVER = 2;
Q_NORM = 3;
Q_HOVER = 4;
LOAD_TAB_NORM = 5;
LOAD_TAB_HOVER = 6;
SAVE_TAB_NORM = 7;
SAVE_TAB_HOVER = 8;
TAB_NORM_1 = 9;
TAB_HOVER_1 = 10;
TAB_NORM_2 = 11;
TAB_HOVER_2 = 12;
TAB_NORM_3 = 13;
TAB_HOVER_3 = 14;
TAB_NORM_4 = 15;
TAB_HOVER_4 = 16;
LOC_ICON_NORM = 17;
LOC_ICON_HOVER = 18;
LOC_EXIT_NORM = 19;
LOC_EXIT_HOVER = 20;
LOC_MAP = 21;
LOC_NAV = 22;
LOC_BORD_TOP = 23;
LOC_BORD_BOTTOM = 24;
LOC_BORD_LEFT = 25;
LOC_BORD_RIGHT = 26;
LOC_BOX_TOP = 27;
LOC_BOX_LEFT = 28;
LOC_LABEL = 29;
TAB_HINT = 30;

var
frmMain: TForm;
time: TTimer;

tImages: Array[0..IMG_COUNT - 1] of TImage;

frmBitmaps: Array [0..BITMAP_COUNT - 1] of Integer;

isActiveImage: Array[0..IMG_COUNT - 1] of Boolean;
isLeftTab: Array[IMG_TAB_NORM_1..IMG_TAB_NORM_4] of Boolean;
isActivePanel: Array[0..PANEL_COUNT - 1] of Boolean;

MapDragStartX, MapDragStartY: Integer;


panels: array [IMG_TAB_NORM_1..IMG_TAB_NORM_4] of TPanel;


procedure OutsideBox(l,t,r,b, obj: integer);
begin
if tImages[obj].Left > l then
tImages[obj].Left := l;
if tImages[obj].Top > t then
tImages[obj].Top := t;
if tImages[obj].Left < r then
tImages[obj].Left := r;
if tImages[obj].Top < b then
tImages[obj].Top := b;
end;

procedure OnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
BoundL, BoundT: Extended;
begin
case sender of
tImages[IMG_LOC_MAP]:
begin
MapDragStartX := x;
MapDragStartY := y;
end;
tImages[IMG_LOC_NAV]:
begin
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x + (x - left), {T} y + (y - top), {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

OutsideBox(0,0,-345, -354, IMG_LOC_MAP);
end;
end;
end;

var sended: Tobject;
accel, move: integer;
cons: array [IMG_TAB_NORM_1..IMG_TAB_NORM_4] of integer;
procedure TimerTabClick(Sender: TObject);
var
senderTab, i, CurrentPanel, e, temp, d, top, bottom: Integer;
truth: boolean;
begin
for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_4 do
if (Sended = tImages[i]) then
senderTab := i;

if isLeftTab[senderTab] then
begin
d := 1
top := IMG_TAB_NORM_4
bottom := senderTab
end else
begin
d := -1;
top := senderTab
bottom := IMG_TAB_NORM_1
end;
truth := isLeftTab[senderTab];

for i := bottom to top do
if isLeftTab[i] = truth then
begin
if move = 0 then
for e := bottom to top do
cons[e] := tImages[e].Left;
if temp = 0 then
begin
accel := accel + 2;
move := move + accel;
end;
tImages[i].Left := tImages[i].Left + accel * d;
temp := 1;
end;
if move >= 380 then
begin
for e := bottom to top do
if isLeftTab[e] = truth then
begin
tImages[e].Left := cons[e] + 380 * d;
isLeftTab[e] := not truth;
end;
move := 0;
time.ENABLED := false;
end;
if truth then
CurrentPanel := sendertab - IMG_TAB_NORM_1
else
CurrentPanel := sendertab - IMG_TAB_NORM_1 + 1;
for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_4 do
begin
if i = currentPanel then
begin
panels[i].left := panels[i].left + accel * d;
panels[i].width := panels[i].width - accel * d;
end else
if panels[i].width <> 0 then
begin
if not isLeftTab[i] = truth then
panels[i].width := 0;
panels[i].left := panels[i].left - accel * d;
panels[i].width := panels[i].width + accel * d;
end;
end;

for i := PANEL_1 to PANEL_5 do
isActivePanel[i] := i = CurrentPanel;

//WriteLn(CurrentPanel);

for i := IMG_LOC_ICON_NORM to IMG_TAB_HINT do
tImages[i].Visible := isActivePanel[PANEL_1];
end;

procedure TabClick(Sender: TObject);
begin
if not time.ENABLED then
begin
accel := 0;
time.enabled := not time.enabled;
sended := Sender;
end;
end;

procedure LocViewer(Sender: TObject);
var i: Integer;
am: TintegerArray;
tru: boolean;
begin
am := [IMG_LOC_ICON_NORM, IMG_TAB_HINT, IMG_LOC_LABEL];
case Sender of
tImages[IMG_LOC_ICON_NORM]: tru := true;
tImages[IMG_LOC_EXIT_NORM]: tru := false;
end;

for i := IMG_LOC_EXIT_NORM to IMG_LOC_BOX_BOTTOM do
tImages[i].Visible := Tru;

for i := 0 to high(am) do
tImages[i].Visible := not tru;
end;

procedure Clicked(Sender: TObject);
var
i: Integer;
begin
for i := 0 to BITMAP_COUNT - 1 do
FreeBitmap(frmBitmaps[i]);
frmMain.ModalResult := mrOk;
end;

procedure MouseMoved(Sender: TObject; Shift: TShiftState; x, y: Integer);
var
hi, i, bmp, xdif, ydif, h: Integer;
BoundL, BoundT: Extended;
imgSwap, bmpArr, imgArr: Array of Integer;
begin
bmpArr := [ X_NORM, Q_NORM, LOAD_TAB_NORM,
SAVE_TAB_NORM, TAB_NORM_1, TAB_NORM_2,
TAB_NORM_3, TAB_NORM_4, LOC_ICON_NORM, LOC_EXIT_NORM ]

imgArr := [ IMG_X_NORM, IMG_Q_NORM, IMG_LOAD_TAB_NORM,
IMG_SAVE_TAB_NORM, IMG_TAB_NORM_1, IMG_TAB_NORM_2,
IMG_TAB_NORM_3, IMG_TAB_NORM_4, IMG_LOC_ICON_NORM, IMG_LOC_EXIT_NORM ]
hi := High(bmpArr);
case Sender of
tImages[IMG_BGND], tImages[IMG_LOC_MAP]:
begin
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;

bmp := frmBitmaps[bmpArr[i]];
DrawBitmap(bmp,tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;
end;
for h := 0 to hi do
case Sender of
tImages[imgArr[h]]:
begin
imgSwap := [imgArr[h], frmBitmaps[bmpArr[h] + 1]];
if not (isActiveImage[imgSwap[0]]) then
begin
DrawBitmap(imgSwap[1],tImages[imgSwap[0]].Canvas,0,0);
isActiveImage[imgSwap[0]] := True;
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;
if (i = imgSwap[0] - 1) then
Continue;
if imgSwap[0] = IMG_LOC_EXIT_NORM then
if (i = imgSwap[0] - 2) then
Continue;
if imgSwap[0] = IMG_LOC_ICON_NORM then
if (i = imgSwap[0] - 12) then
Continue;
bmp := frmBitmaps[bmpArr[i]];
DrawBitmap(bmp, tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;
end;
end;
case sender of
tImages[IMG_LOC_MAP]:
begin
if not IsMouseButtonDown(1) then exit;
xdif := x - MapDragStartX;
ydif := y - MapDragStartY;
tImages[IMG_LOC_MAP].Left := tImages[IMG_LOC_MAP].Left + xdif;
tImages[IMG_LOC_MAP].Top := tImages[IMG_LOC_MAP].Top + ydif;

OutsideBox(0,0,-854, -765, IMG_LOC_MAP);

BoundL := -tImages[IMG_LOC_MAP].Left / 7.234 + 376;
BoundT := -tImages[IMG_LOC_MAP].Top / 7.234 + 216;


with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} Round(BoundL), {T} Round(BoundT), {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);
end;
tImages[IMG_LOC_NAV]:
begin
if not IsMouseButtonDown(1) then exit;
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x - 55 - 100, {T} y - 40 - 100, {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

OutsideBox(0, 0, -854, -765, IMG_LOC_MAP);
end;
end;
end;

procedure OnClickEvents(Sender: TObject);
begin
case Sender of
tImages[IMG_X_NORM]: Clicked(Sender);
tImages[IMG_TAB_NORM_1], tImages[IMG_TAB_NORM_2],tImages[IMG_TAB_NORM_3], tImages[IMG_TAB_NORM_4]: TabClick(Sender);
tImages[IMG_LOC_ICON_NORM], tImages[IMG_LOC_EXIT_NORM]: LocViewer(Sender);
end;
end;

procedure InitForm;
var
Image, bmp, hi, i: Integer;
consts: TintegerArray;
bmpArr: TStringArray;
xy, wh: TPointArray;
visibl: TBoolArray;
begin
bmpArr := ['BGND','X_NORM','X_HOVER','Q_NORM','Q_HOVER','LOAD_TAB_NORM','LOAD_TAB_HOVER','SAVE_TAB_NORM','SAVE_TAB_HOVER','TAB_NORM_1','TAB_HOVER_1','TAB_NORM_2','TAB_HOVER_2','TAB_NORM_3','TAB_HOVER_3','TAB_NORM_4','TAB_HOVER_4','LOC_ICON_NORM','LOC_ICON_HOVER','LOC_EXIT_NORM','LOC_EXIT_HOVER','LOC_MAP','LOC_NAV','LOC_BORD_TOP','LOC_BORD_BOTTOM','LOC_BORD_LEFT','LOC_BORD_RIGHT','LOC_BOX_TOP','LOC_BOX_LEFT','LOC_LABEL','TAB_HINT'];
hi := High(frmBitmaps);
for i := 0 to hi do
frmBitmaps[i] := LoadBitmap(ScriptPath + 'Bitmaps\' + bmpArr[i] + '.png');

frmMain := TForm.Create(nil);
with frmMain do
begin
SetBounds({L} 100, {T} 100, {W} 600, {H} 400);
//Position := poScreenCenter;
BorderStyle := bsNone;
end;

time := TTimer.Create(frmMain);
time.ONTIMER := @TimerTabClick;
time.INTERVAL := 10;
time.ENABLED := false;

xy := [Point(0,0), Point(575,7), Point(557,7), Point(7,69), Point(81,69), Point(390,100), Point(440,100), Point(490,100), Point(540,100), Point(179,204), Point(-300,0), Point(369,209), Point(475,7), Point(0,0), Point(0,393), Point(0,7), Point(593,7), Point(Round( 300 / 7.234 + 376), 216), Point(Round( 300 / 7.234 + 376), 216 + 1), Point(Round( 300 / 7.234 + 376) + 83, 216 + 1), Point(Round( 300 / 7.234 + 376), 216 + 1 + 54), Point(156,250), Point(208,379)];
wh := [Point(600,400), Point(18,18), Point(18,18), Point(74,22), Point(74,22), Point(50,290), Point(50,290), Point(50,290), Point(50,290), Point(40,41), Point(1454,1165), Point(215,175), Point(119,22), Point(600,7), Point(600,7), Point(7,386), Point(7,386), Point(83, 1), Point(1,55), Point(1,55), Point(83,1), Point(87,11), Point(174,10)];
visibl := [true, true, true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, true, true];
consts := [BGND, X_NORM, Q_NORM, LOAD_TAB_NORM,SAVE_TAB_NORM,TAB_NORM_1, TAB_NORM_2, TAB_NORM_3, TAB_NORM_4, LOC_ICON_NORM, LOC_MAP, LOC_NAV, LOC_EXIT_NORM, LOC_BORD_TOP, LOC_BORD_BOTTOM, LOC_BORD_LEFT, LOC_BORD_RIGHT, LOC_BOX_TOP, LOC_BOX_LEFT, LOC_BOX_LEFT, LOC_BOX_TOP, LOC_LABEL, TAB_HINT];
for Image := 0 to IMG_COUNT - 1 do
begin
tImages[Image] := TImage.Create(frmMain);
with tImages[Image] do
begin
Parent := frmMain;
SetBounds(xy[Image].x, xy[Image].y, wh[Image].x, wh[Image].y);
bmp := frmBitmaps[consts[image]];
OnMouseMove := @MouseMoved;
ONMOUSEDOWN := @OnMouseDown;
OnClick := @OnClickEvents;
isActiveImage[Image] := False;
if (Image > IMG_TAB_NORM_1) and (Image < IMG_TAB_NORM_4) then
isLeftTab[Image] := false;
visible := Visibl[Image];
end;
DrawBitmap(bmp, tImages[Image].canvas, 0, 0);
end;

isActivePanel[Panel_1] := True;
for i := 0 to high(IsActivePanel) do
isActivePanel[i] := False;

for i := low(panels) to high(panels) do
begin
panels[i] := TPanel.Create(frmMain);
panels[i].parent := frmMain;
panels[i].SetBounds(tImages[i].left + tImages[i].width,tImages[i].top, 0, tImages[i].height);
end;
end;

procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;

procedure ShowFormModal;
begin
frmMain.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;

begin
try
SafeInitForm;
SafeShowFormModal;
finally
time.ENABLED := false;
time.Free;
frmMain.Free;
except
Writeln(ExceptionToString(ExceptionType, ExceptionParam));
end;
end.


and without it:
program MSIForm;

const


PANEL_COUNT = 5;
PANEL_1 = 0;
PANEL_2 = 1;
PANEL_3 = 2;
PANEL_4 = 3;
PANEL_5 = 4;


IMG_COUNT = 23;
// Used in frmMain
IMG_BGND = 0;
IMG_X_NORM = 1;
IMG_Q_NORM = 2;
IMG_LOAD_TAB_NORM = 3;
IMG_SAVE_TAB_NORM = 4;
IMG_TAB_NORM_1 = 5;
IMG_TAB_NORM_2 = 6;
IMG_TAB_NORM_3 = 7;
IMG_TAB_NORM_4 = 8;

IMG_LOC_ICON_NORM = 9;
IMG_LOC_EXIT_NORM = 10;
IMG_LOC_MAP = 11;
IMG_LOC_NAV = 12;
IMG_LOC_BORD_TOP = 13;
IMG_LOC_BORD_BOTTOM = 14;
IMG_LOC_BORD_LEFT = 15;
IMG_LOC_BORD_RIGHT = 16;
IMG_LOC_BOX_TOP = 17;
IMG_LOC_BOX_LEFT = 18;
IMG_LOC_BOX_RIGHT = 19;
IMG_LOC_BOX_BOTTOM = 20;

// Used in Panel 0 (Is also used for frmMain)
IMG_LOC_LABEL = 21;
IMG_TAB_HINT = 22;

// Used in Panel 1

// Used in Panel 2

// Used in Panel 3

// Used in Panel 4

BITMAP_COUNT = 31;
BGND = 0;
X_NORM = 1;
X_HOVER = 2;
Q_NORM = 3;
Q_HOVER = 4;
LOAD_TAB_NORM = 5;
LOAD_TAB_HOVER = 6;
SAVE_TAB_NORM = 7;
SAVE_TAB_HOVER = 8;
TAB_NORM_1 = 9;
TAB_HOVER_1 = 10;
TAB_NORM_2 = 11;
TAB_HOVER_2 = 12;
TAB_NORM_3 = 13;
TAB_HOVER_3 = 14;
TAB_NORM_4 = 15;
TAB_HOVER_4 = 16;
LOC_ICON_NORM = 17;
LOC_ICON_HOVER = 18;
LOC_EXIT_NORM = 19;
LOC_EXIT_HOVER = 20;
LOC_MAP = 21;
LOC_NAV = 22;
LOC_BORD_TOP = 23;
LOC_BORD_BOTTOM = 24;
LOC_BORD_LEFT = 25;
LOC_BORD_RIGHT = 26;
LOC_BOX_TOP = 27;
LOC_BOX_LEFT = 28;
LOC_LABEL = 29;
TAB_HINT = 30;

var
frmMain: TForm;
time: TTimer;

tImages: Array[0..IMG_COUNT - 1] of TImage;

frmBitmaps: Array [0..BITMAP_COUNT - 1] of Integer;

isActiveImage: Array[0..IMG_COUNT - 1] of Boolean;
isLeftTab: Array[IMG_TAB_NORM_1..IMG_TAB_NORM_4] of Boolean;
isActivePanel: Array[0..PANEL_COUNT - 1] of Boolean;

MapDragStartX, MapDragStartY: Integer;


panels: array [IMG_TAB_NORM_1..IMG_TAB_NORM_4] of TPanel;


procedure OutsideBox(l,t,r,b, obj: integer);
begin
if tImages[obj].Left > l then
tImages[obj].Left := l;
if tImages[obj].Top > t then
tImages[obj].Top := t;
if tImages[obj].Left < r then
tImages[obj].Left := r;
if tImages[obj].Top < b then
tImages[obj].Top := b;
end;

procedure OnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
BoundL, BoundT: Extended;
begin
case sender of
tImages[IMG_LOC_MAP]:
begin
MapDragStartX := x;
MapDragStartY := y;
end;
tImages[IMG_LOC_NAV]:
begin
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x + (x - left), {T} y + (y - top), {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

OutsideBox(0,0,-345, -354, IMG_LOC_MAP);
end;
end;
end;

var sended: Tobject;
accel, move: integer;
cons: array [IMG_TAB_NORM_1..IMG_TAB_NORM_4] of integer;
procedure TimerTabClick(Sender: TObject);
var
senderTab, i, CurrentPanel, e, temp, d, top, bottom: Integer;
truth: boolean;
begin
for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_4 do
if (Sended = tImages[i]) then
senderTab := i;

if isLeftTab[senderTab] then
begin
d := 1
top := IMG_TAB_NORM_4
bottom := senderTab
end else
begin
d := -1;
top := senderTab
bottom := IMG_TAB_NORM_1
end;
truth := isLeftTab[senderTab];

for i := bottom to top do
if isLeftTab[i] = truth then
begin
if move = 0 then
for e := bottom to top do
cons[e] := tImages[e].Left;
if temp = 0 then
begin
accel := accel + 2;
move := move + accel;
end;
tImages[i].Left := tImages[i].Left + accel * d;
temp := 1;
end;
if move >= 380 then
begin
for e := bottom to top do
if isLeftTab[e] = truth then
begin
tImages[e].Left := cons[e] + 380 * d;
isLeftTab[e] := not truth;
end;
move := 0;
time.ENABLED := false;
end;
if truth then
CurrentPanel := sendertab - IMG_TAB_NORM_1
else
CurrentPanel := sendertab - IMG_TAB_NORM_1 + 1;
for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_4 do
begin
if i = currentPanel then
begin
panels[i].left := panels[i].left + accel * d;
panels[i].width := panels[i].width - accel * d;
end else
if panels[i].width <> 0 then
begin
if not isLeftTab[i] = truth then
panels[i].width := 0;
panels[i].left := panels[i].left - accel * d;
panels[i].width := panels[i].width + accel * d;
end;
end;

for i := PANEL_1 to PANEL_5 do
isActivePanel[i] := i = CurrentPanel;

//WriteLn(CurrentPanel);

for i := IMG_LOC_ICON_NORM to IMG_TAB_HINT do
tImages[i].Visible := isActivePanel[PANEL_1];
end;

procedure TabClick(Sender: TObject);
begin
if not time.ENABLED then
begin
accel := 0;
time.enabled := not time.enabled;
sended := Sender;
end;
end;

procedure LocViewer(Sender: TObject);
var i: Integer;
am: TintegerArray;
tru: boolean;
begin
am := [IMG_LOC_ICON_NORM, IMG_TAB_HINT, IMG_LOC_LABEL];
case Sender of
tImages[IMG_LOC_ICON_NORM]: tru := true;
tImages[IMG_LOC_EXIT_NORM]: tru := false;
end;

for i := IMG_LOC_EXIT_NORM to IMG_LOC_BOX_BOTTOM do
tImages[i].Visible := Tru;

for i := 0 to high(am) do
tImages[i].Visible := not tru;
end;

procedure Clicked(Sender: TObject);
var
i: Integer;
begin
for i := 0 to BITMAP_COUNT - 1 do
FreeBitmap(frmBitmaps[i]);
frmMain.ModalResult := mrOk;
end;

procedure MouseMoved(Sender: TObject; Shift: TShiftState; x, y: Integer);
var
hi, i, bmp, xdif, ydif, h: Integer;
BoundL, BoundT: Extended;
imgSwap, bmpArr, imgArr: Array of Integer;
begin
bmpArr := [ X_NORM, Q_NORM, LOAD_TAB_NORM,
SAVE_TAB_NORM, TAB_NORM_1, TAB_NORM_2,
TAB_NORM_3, TAB_NORM_4, LOC_ICON_NORM, LOC_EXIT_NORM ]

imgArr := [ IMG_X_NORM, IMG_Q_NORM, IMG_LOAD_TAB_NORM,
IMG_SAVE_TAB_NORM, IMG_TAB_NORM_1, IMG_TAB_NORM_2,
IMG_TAB_NORM_3, IMG_TAB_NORM_4, IMG_LOC_ICON_NORM, IMG_LOC_EXIT_NORM ]
hi := High(bmpArr);
case Sender of
tImages[IMG_BGND], tImages[IMG_LOC_MAP]:
begin
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;

bmp := frmBitmaps[bmpArr[i]];
DrawBitmap(bmp,tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;
end;
for h := 0 to hi do
case Sender of
tImages[imgArr[h]]:
begin
imgSwap := [imgArr[h], frmBitmaps[bmpArr[h] + 1]];
if not (isActiveImage[imgSwap[0]]) then
begin
DrawBitmap(imgSwap[1],tImages[imgSwap[0]].Canvas,0,0);
isActiveImage[imgSwap[0]] := True;
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;
if (i = imgSwap[0] - 1) then
Continue;
if imgSwap[0] = IMG_LOC_EXIT_NORM then
if (i = imgSwap[0] - 2) then
Continue;
if imgSwap[0] = IMG_LOC_ICON_NORM then
if (i = imgSwap[0] - 12) then
Continue;
bmp := frmBitmaps[bmpArr[i]];
DrawBitmap(bmp, tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;
end;
end;
case sender of
tImages[IMG_LOC_MAP]:
begin
if not IsMouseButtonDown(1) then exit;
xdif := x - MapDragStartX;
ydif := y - MapDragStartY;
tImages[IMG_LOC_MAP].Left := tImages[IMG_LOC_MAP].Left + xdif;
tImages[IMG_LOC_MAP].Top := tImages[IMG_LOC_MAP].Top + ydif;

OutsideBox(0,0,-854, -765, IMG_LOC_MAP);

BoundL := -tImages[IMG_LOC_MAP].Left / 7.234 + 376;
BoundT := -tImages[IMG_LOC_MAP].Top / 7.234 + 216;


with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} Round(BoundL), {T} Round(BoundT), {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);
end;
tImages[IMG_LOC_NAV]:
begin
if not IsMouseButtonDown(1) then exit;
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x - 55 - 100, {T} y - 40 - 100, {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

OutsideBox(0, 0, -854, -765, IMG_LOC_MAP);
end;
end;
end;

procedure OnClickEvents(Sender: TObject);
begin
case Sender of
tImages[IMG_X_NORM]: Clicked(Sender);
tImages[IMG_TAB_NORM_1], tImages[IMG_TAB_NORM_2],tImages[IMG_TAB_NORM_3], tImages[IMG_TAB_NORM_4]: TabClick(Sender);
tImages[IMG_LOC_ICON_NORM], tImages[IMG_LOC_EXIT_NORM]: LocViewer(Sender);
end;
end;

procedure InitForm;
var
Image, bmp, hi, i: Integer;
consts: TintegerArray;
bmpArr: TStringArray;
xy, wh: TPointArray;
visibl: TBoolArray;
begin
bmpArr := ['BGND','X_NORM','X_HOVER','Q_NORM','Q_HOVER','LOAD_TAB_NORM','LOAD_TAB_HOVER','SAVE_TAB_NORM','SAVE_TAB_HOVER','TAB_NORM_1','TAB_HOVER_1','TAB_NORM_2','TAB_HOVER_2','TAB_NORM_3','TAB_HOVER_3','TAB_NORM_4','TAB_HOVER_4','LOC_ICON_NORM','LOC_ICON_HOVER','LOC_EXIT_NORM','LOC_EXIT_HOVER','LOC_MAP','LOC_NAV','LOC_BORD_TOP','LOC_BORD_BOTTOM','LOC_BORD_LEFT','LOC_BORD_RIGHT','LOC_BOX_TOP','LOC_BOX_LEFT','LOC_LABEL','TAB_HINT'];
hi := High(frmBitmaps);
for i := 0 to hi do
frmBitmaps[i] := LoadBitmap(ScriptPath + 'Bitmaps\' + bmpArr[i] + '.png');

frmMain := TForm.Create(nil);
with frmMain do
begin
SetBounds({L} 100, {T} 100, {W} 600, {H} 400);
//Position := poScreenCenter;
BorderStyle := bsNone;
end;

time := TTimer.Create(frmMain);
time.ONTIMER := @TimerTabClick;
time.INTERVAL := 10;
time.ENABLED := false;

for Image := 0 to IMG_TAB_HINT do
begin
tImages[Image] := TImage.Create(frmMain);
with tImages[Image] do
begin
Parent := frmMain;
case Image of
IMG_BGND:
begin
SetBounds({L} 0, {T} 0, {W} 600, {H} 400);
bmp := frmBitmaps[BGND];
OnMouseMove := @MouseMoved;
isActiveImage[BGND] := False;
end;

IMG_X_NORM:
begin
SetBounds({L} 575, {T} 7, {W} 18, {H} 18);
bmp := frmBitmaps[X_NORM];
OnClick := @Clicked;
OnMouseMove := @MouseMoved;
isActiveImage[IMG_X_NORM] := False;
end;

IMG_Q_NORM:
begin
SetBounds({L} 557, {T} 7, {W} 18, {H} 18);
bmp := frmBitmaps[Q_NORM];
OnMouseMove := @MouseMoved;
isActiveImage[IMG_Q_NORM] := False;
end;

IMG_LOAD_TAB_NORM:
begin
SetBounds({L} 7, {T} 69, {W} 74, {H} 22);
bmp := frmBitmaps[LOAD_TAB_NORM];
OnMouseMove := @MouseMoved;
isActiveImage[IMG_LOAD_TAB_NORM] := False;
end;

IMG_SAVE_TAB_NORM:
begin
SetBounds({L} 81, {T} 69, {W} 74, {H} 22);
bmp := frmBitmaps[SAVE_TAB_NORM];
OnMouseMove := @MouseMoved;
isActiveImage[IMG_SAVE_TAB_NORM] := False;
end;

IMG_TAB_NORM_1:
begin
SetBounds({L} 390, {T} 100, {W} 50, {H} 290);
bmp := frmBitmaps[TAB_NORM_1];
OnMouseMove := @MouseMoved;
OnClick := @TabClick;
isActiveImage[IMG_TAB_NORM_1] := False;
isLeftTab[IMG_TAB_NORM_1] := False;
end;

IMG_TAB_NORM_2:
begin
SetBounds({L} 440, {T} 100, {W} 50, {H} 290);
bmp := frmBitmaps[TAB_NORM_2];
OnMouseMove := @MouseMoved;
OnClick := @TabClick;
isActiveImage[IMG_TAB_NORM_2] := False;
isLeftTab[IMG_TAB_NORM_1] := False;
end;

IMG_TAB_NORM_3:
begin
SetBounds({L} 490, {T} 100, {W} 50, {H} 290);
bmp := frmBitmaps[TAB_NORM_3];
OnMouseMove := @MouseMoved;
OnClick := @TabClick;
isActiveImage[BGND] := False;
isLeftTab[IMG_TAB_NORM_1] := False;
end;

IMG_TAB_NORM_4:
begin
SetBounds({L} 540, {T} 100, {W} 50, {H} 290);
bmp := frmBitmaps[TAB_NORM_4];
OnMouseMove := @MouseMoved;
OnClick := @TabClick;
isActiveImage[IMG_TAB_NORM_4] := False;
isLeftTab[IMG_TAB_NORM_1] := False;
end;

IMG_LOC_ICON_NORM:
begin
SetBounds({L} 179, {T} 204, {W} 40, {H} 41);
bmp := frmBitmaps[LOC_ICON_NORM];
OnClick := @LocViewer;
OnMouseMove := @MouseMoved;
isActiveImage[IMG_LOC_ICON_NORM] := False;
end;


// Location Viewer

IMG_LOC_MAP:
begin
SetBounds({L} -300, {T} 0, {W} 1454, {H} 1165);
bmp := frmBitmaps[LOC_MAP];
ONMOUSEDOWN := @OnMouseDown;
OnMouseMove := @MouseMoved;
isActiveImage[IMG_LOC_MAP] := False;
Visible := False;
end;

IMG_LOC_NAV:
begin
SetBounds({L} 369, {T} 209, {W} 215, {H} 175);
bmp := frmBitmaps[LOC_NAV];
ONMOUSEDOWN := @OnMouseDown;
OnMouseMove := @MouseMoved;
isActiveImage[IMG_LOC_NAV] := False;
Visible := False;
end;

IMG_LOC_EXIT_NORM:
begin
SetBounds({L} 475, {T} 7, {W} 119, {H} 22);
bmp := frmBitmaps[LOC_EXIT_NORM];
OnClick := @LocViewer;
OnMouseMove := @MouseMoved;
isActiveImage[IMG_LOC_MAP] := False;
Visible := False;
end;

IMG_LOC_BORD_TOP:
begin
SetBounds({L} 0, {T} 0, {W} 600, {H} 7);
bmp := frmBitmaps[LOC_BORD_TOP];
isActiveImage[IMG_LOC_BORD_TOP] := False;
Visible := False;
end;

IMG_LOC_BORD_BOTTOM:
begin
SetBounds({L} 0, {T} 393, {W} 600, {H} 7);
bmp := frmBitmaps[LOC_BORD_BOTTOM];
isActiveImage[IMG_LOC_BORD_BOTTOM] := False;
Visible := False;
end;

IMG_LOC_BORD_LEFT:
begin
SetBounds({L} 0, {T} 7, {W} 7, {H} 386);
bmp := frmBitmaps[LOC_BORD_LEFT];
isActiveImage[IMG_LOC_BORD_LEFT] := False;
Visible := False;
end;

IMG_LOC_BORD_RIGHT:
begin
SetBounds({L} 593, {T} 7, {W} 7, {H} 386);
bmp := frmBitmaps[LOC_BORD_RIGHT];
isActiveImage[IMG_LOC_BORD_RIGHT] := False;
Visible := False;
end;

IMG_LOC_BOX_TOP:
begin
SetBounds({L} Round(-tImages[IMG_LOC_MAP].Left / 7.234 + 376), {T} Round(-tImages[IMG_LOC_MAP].Top / 7.234 + 216), {W} 83, {H} 1);
bmp := frmBitmaps[LOC_BOX_TOP];
isActiveImage[IMG_LOC_BOX_TOP] := False;
Visible := False;
end;

IMG_LOC_BOX_LEFT:
begin
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
bmp := frmBitmaps[LOC_BOX_LEFT];
isActiveImage[IMG_LOC_BOX_LEFT] := False;
Visible := False;
end;

IMG_LOC_BOX_RIGHT:
begin
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
bmp := frmBitmaps[LOC_BOX_LEFT];
isActiveImage[IMG_LOC_BOX_RIGHT] := False;
Visible := False;
end;

IMG_LOC_BOX_BOTTOM:
begin
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);
bmp := frmBitmaps[LOC_BOX_TOP];
isActiveImage[IMG_LOC_BOX_BOTTOM] := False;
Visible := False;
end;

IMG_LOC_LABEL:
begin
SetBounds({L} 156, {T} 250, {W} 87, {H} 11);
bmp := frmBitmaps[LOC_LABEL];
isActiveImage[IMG_LOC_LABEL] := False;
Visible := True;
end;

IMG_TAB_HINT:
begin
SetBounds({L} 208, {T} 379, {W} 174, {H} 10);
bmp := frmBitmaps[TAB_HINT];
isActiveImage[IMG_TAB_HINT] := False;
Visible := True;
end;

end;
end;
DrawBitmap(bmp, tImages[Image].canvas, 0, 0);
end;

isActivePanel[Panel_1] := True;
for i := 0 to high(IsActivePanel) do
isActivePanel[i] := False;

for i := low(panels) to high(panels) do
begin
panels[i] := TPanel.Create(frmMain);
panels[i].parent := frmMain;
panels[i].SetBounds(tImages[i].left + tImages[i].width,tImages[i].top, 0, tImages[i].height);
end;
end;

procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;

procedure ShowFormModal;
begin
frmMain.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;

begin
try
SafeInitForm;
SafeShowFormModal;
finally
time.ENABLED := false;
time.Free;
frmMain.Free;
except
Writeln(ExceptionToString(ExceptionType, ExceptionParam));
end;
end.

They both work somewhat. But without my shortening, the map works as advertised, though you can't get out of the form once you're in it because it doesn't pop up the exit button. With mine it gets all screwed up but you can click the map to get out :p. And with both, when you click the first tab when it is on the left, it goes into the map.

Other than all of that, it works :)

EDIT: but i think the way the panel stuff is being done at the moment is a bit silly. Once this is all fixed, I think the panel clicking should be fixed. I don't know if anyone else agrees, but when you click a panel, i think, it should always move to the same space. Right now it doesn't and that sort of hinders my panel idea.

After that's fixed, switching to actual panels is next (because i think my problems with the panels may be being caused by the above problem). Right now my tests have been done on actual TPanels, but it should work the same on TImages. So, then the location bits and whatnot can all be moved to be separate from the actual form loading, which should make the kind of problems that are happening right now (the logic of the form being muddled by a specific panel's logic) happen less.

I don't know if you agree, but i think that the location thing should be on an actual panel, like in between the tabs rather than covering everything like it does now. I think it would make it easier to code because you wouldn't have to have all this showing and hiding logic, plus it makes the form more consistent. If not, then I would suggest adding a hidden panel to put the actual map and such on, and keeping it separate from the panel that holds the button to get to the map.

and finally, i didn't get any feedback about my mock up of the player declarations. I dunno if I could even get it to work well, but i like the concept, and i think the next and back buttons that I had added on the bottom at least would make it more apparent to the user what they're supposed to do to navigate the form.

ReadySteadyGo

2010-07-02 11:52:58

From: Dan Cardin
Well, now's the time for me to be at least a little embarrassed. It may not be the way that I load the images, but my shortening of that area has been part of the reason why I can't get the location viewer to work correctly (and all this time i've been saying how much easier it is :p). I think it's more likely that I either: have the order wrong somehow, am mixing up the on click events, or the script was hardcoded to work in the order that it was before and after changing that it got screwed up. The last part seems the most likely, but I can't seem to find it.

with my shortening:
program MSIForm;

const


PANEL_COUNT = 5;
PANEL_1 = 0;
PANEL_2 = 1;
PANEL_3 = 2;
PANEL_4 = 3;
PANEL_5 = 4;


IMG_COUNT = 23;
// Used in frmMain
IMG_BGND = 0;
IMG_X_NORM = 1;
IMG_Q_NORM = 2;
IMG_LOAD_TAB_NORM = 3;
IMG_SAVE_TAB_NORM = 4;
IMG_TAB_NORM_1 = 5;
IMG_TAB_NORM_2 = 6;
IMG_TAB_NORM_3 = 7;
IMG_TAB_NORM_4 = 8;

IMG_LOC_ICON_NORM = 9;
IMG_LOC_EXIT_NORM = 10;
IMG_LOC_MAP = 11;
IMG_LOC_NAV = 12;
IMG_LOC_BORD_TOP = 13;
IMG_LOC_BORD_BOTTOM = 14;
IMG_LOC_BORD_LEFT = 15;
IMG_LOC_BORD_RIGHT = 16;
IMG_LOC_BOX_TOP = 17;
IMG_LOC_BOX_LEFT = 18;
IMG_LOC_BOX_RIGHT = 19;
IMG_LOC_BOX_BOTTOM = 20;

// Used in Panel 0 (Is also used for frmMain)
IMG_LOC_LABEL = 21;
IMG_TAB_HINT = 22;

// Used in Panel 1

// Used in Panel 2

// Used in Panel 3

// Used in Panel 4

BITMAP_COUNT = 31;
BGND = 0;
X_NORM = 1;
X_HOVER = 2;
Q_NORM = 3;
Q_HOVER = 4;
LOAD_TAB_NORM = 5;
LOAD_TAB_HOVER = 6;
SAVE_TAB_NORM = 7;
SAVE_TAB_HOVER = 8;
TAB_NORM_1 = 9;
TAB_HOVER_1 = 10;
TAB_NORM_2 = 11;
TAB_HOVER_2 = 12;
TAB_NORM_3 = 13;
TAB_HOVER_3 = 14;
TAB_NORM_4 = 15;
TAB_HOVER_4 = 16;
LOC_ICON_NORM = 17;
LOC_ICON_HOVER = 18;
LOC_EXIT_NORM = 19;
LOC_EXIT_HOVER = 20;
LOC_MAP = 21;
LOC_NAV = 22;
LOC_BORD_TOP = 23;
LOC_BORD_BOTTOM = 24;
LOC_BORD_LEFT = 25;
LOC_BORD_RIGHT = 26;
LOC_BOX_TOP = 27;
LOC_BOX_LEFT = 28;
LOC_LABEL = 29;
TAB_HINT = 30;

var
frmMain: TForm;
time: TTimer;

tImages: Array[0..IMG_COUNT - 1] of TImage;

frmBitmaps: Array [0..BITMAP_COUNT - 1] of Integer;

isActiveImage: Array[0..IMG_COUNT - 1] of Boolean;
isLeftTab: Array[IMG_TAB_NORM_1..IMG_TAB_NORM_4] of Boolean;
isActivePanel: Array[0..PANEL_COUNT - 1] of Boolean;

MapDragStartX, MapDragStartY: Integer;


panels: array [IMG_TAB_NORM_1..IMG_TAB_NORM_4] of TPanel;


procedure OutsideBox(l,t,r,b, obj: integer);
begin
if tImages[obj].Left > l then
tImages[obj].Left := l;
if tImages[obj].Top > t then
tImages[obj].Top := t;
if tImages[obj].Left < r then
tImages[obj].Left := r;
if tImages[obj].Top < b then
tImages[obj].Top := b;
end;

procedure OnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
BoundL, BoundT: Extended;
begin
case sender of
tImages[IMG_LOC_MAP]:
begin
MapDragStartX := x;
MapDragStartY := y;
end;
tImages[IMG_LOC_NAV]:
begin
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x + (x - left), {T} y + (y - top), {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

OutsideBox(0,0,-345, -354, IMG_LOC_MAP);
end;
end;
end;

var sended: Tobject;
accel, move: integer;
cons: array [IMG_TAB_NORM_1..IMG_TAB_NORM_4] of integer;
procedure TimerTabClick(Sender: TObject);
var
senderTab, i, CurrentPanel, e, temp, d, top, bottom: Integer;
truth: boolean;
begin
for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_4 do
if (Sended = tImages[i]) then
senderTab := i;

if isLeftTab[senderTab] then
begin
d := 1
top := IMG_TAB_NORM_4
bottom := senderTab
end else
begin
d := -1;
top := senderTab
bottom := IMG_TAB_NORM_1
end;
truth := isLeftTab[senderTab];

for i := bottom to top do
if isLeftTab[i] = truth then
begin
if move = 0 then
for e := bottom to top do
cons[e] := tImages[e].Left;
if temp = 0 then
begin
accel := accel + 2;
move := move + accel;
end;
tImages[i].Left := tImages[i].Left + accel * d;
temp := 1;
end;
if move >= 380 then
begin
for e := bottom to top do
if isLeftTab[e] = truth then
begin
tImages[e].Left := cons[e] + 380 * d;
isLeftTab[e] := not truth;
end;
move := 0;
time.ENABLED := false;
end;
if truth then
CurrentPanel := sendertab - IMG_TAB_NORM_1
else
CurrentPanel := sendertab - IMG_TAB_NORM_1 + 1;
for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_4 do
begin
if i = currentPanel then
begin
panels[i].left := panels[i].left + accel * d;
panels[i].width := panels[i].width - accel * d;
end else
if panels[i].width <> 0 then
begin
if not isLeftTab[i] = truth then
panels[i].width := 0;
panels[i].left := panels[i].left - accel * d;
panels[i].width := panels[i].width + accel * d;
end;
end;

for i := PANEL_1 to PANEL_5 do
isActivePanel[i] := i = CurrentPanel;

//WriteLn(CurrentPanel);

for i := IMG_LOC_ICON_NORM to IMG_TAB_HINT do
tImages[i].Visible := isActivePanel[PANEL_1];
end;

procedure TabClick(Sender: TObject);
begin
if not time.ENABLED then
begin
accel := 0;
time.enabled := not time.enabled;
sended := Sender;
end;
end;

procedure LocViewer(Sender: TObject);
var i: Integer;
am: TintegerArray;
tru: boolean;
begin
am := [IMG_LOC_ICON_NORM, IMG_TAB_HINT, IMG_LOC_LABEL];
case Sender of
tImages[IMG_LOC_ICON_NORM]: tru := true;
tImages[IMG_LOC_EXIT_NORM]: tru := false;
end;

for i := IMG_LOC_EXIT_NORM to IMG_LOC_BOX_BOTTOM do
tImages[i].Visible := Tru;

for i := 0 to high(am) do
tImages[i].Visible := not tru;
end;

procedure Clicked(Sender: TObject);
var
i: Integer;
begin
for i := 0 to BITMAP_COUNT - 1 do
FreeBitmap(frmBitmaps[i]);
frmMain.ModalResult := mrOk;
end;

procedure MouseMoved(Sender: TObject; Shift: TShiftState; x, y: Integer);
var
hi, i, bmp, xdif, ydif, h: Integer;
BoundL, BoundT: Extended;
imgSwap, bmpArr, imgArr: Array of Integer;
begin
bmpArr := [ X_NORM, Q_NORM, LOAD_TAB_NORM,
SAVE_TAB_NORM, TAB_NORM_1, TAB_NORM_2,
TAB_NORM_3, TAB_NORM_4, LOC_ICON_NORM, LOC_EXIT_NORM ]

imgArr := [ IMG_X_NORM, IMG_Q_NORM, IMG_LOAD_TAB_NORM,
IMG_SAVE_TAB_NORM, IMG_TAB_NORM_1, IMG_TAB_NORM_2,
IMG_TAB_NORM_3, IMG_TAB_NORM_4, IMG_LOC_ICON_NORM, IMG_LOC_EXIT_NORM ]
hi := High(bmpArr);
case Sender of
tImages[IMG_BGND], tImages[IMG_LOC_MAP]:
begin
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;

bmp := frmBitmaps[bmpArr[i]];
DrawBitmap(bmp,tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;
end;
for h := 0 to hi do
case Sender of
tImages[imgArr[h]]:
begin
imgSwap := [imgArr[h], frmBitmaps[bmpArr[h] + 1]];
if not (isActiveImage[imgSwap[0]]) then
begin
DrawBitmap(imgSwap[1],tImages[imgSwap[0]].Canvas,0,0);
isActiveImage[imgSwap[0]] := True;
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;
if (i = imgSwap[0] - 1) then
Continue;
if imgSwap[0] = IMG_LOC_EXIT_NORM then
if (i = imgSwap[0] - 2) then
Continue;
if imgSwap[0] = IMG_LOC_ICON_NORM then
if (i = imgSwap[0] - 12) then
Continue;
bmp := frmBitmaps[bmpArr[i]];
DrawBitmap(bmp, tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;
end;
end;
case sender of
tImages[IMG_LOC_MAP]:
begin
if not IsMouseButtonDown(1) then exit;
xdif := x - MapDragStartX;
ydif := y - MapDragStartY;
tImages[IMG_LOC_MAP].Left := tImages[IMG_LOC_MAP].Left + xdif;
tImages[IMG_LOC_MAP].Top := tImages[IMG_LOC_MAP].Top + ydif;

OutsideBox(0,0,-854, -765, IMG_LOC_MAP);

BoundL := -tImages[IMG_LOC_MAP].Left / 7.234 + 376;
BoundT := -tImages[IMG_LOC_MAP].Top / 7.234 + 216;


with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} Round(BoundL), {T} Round(BoundT), {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);
end;
tImages[IMG_LOC_NAV]:
begin
if not IsMouseButtonDown(1) then exit;
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x - 55 - 100, {T} y - 40 - 100, {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

OutsideBox(0, 0, -854, -765, IMG_LOC_MAP);
end;
end;
end;

procedure OnClickEvents(Sender: TObject);
begin
case Sender of
tImages[IMG_X_NORM]: Clicked(Sender);
tImages[IMG_TAB_NORM_1], tImages[IMG_TAB_NORM_2],tImages[IMG_TAB_NORM_3], tImages[IMG_TAB_NORM_4]: TabClick(Sender);
tImages[IMG_LOC_ICON_NORM], tImages[IMG_LOC_EXIT_NORM]: LocViewer(Sender);
end;
end;

procedure InitForm;
var
Image, bmp, hi, i: Integer;
consts: TintegerArray;
bmpArr: TStringArray;
xy, wh: TPointArray;
visibl: TBoolArray;
begin
bmpArr := ['BGND','X_NORM','X_HOVER','Q_NORM','Q_HOVER','LOAD_TAB_NORM','LOAD_TAB_HOVER','SAVE_TAB_NORM','SAVE_TAB_HOVER','TAB_NORM_1','TAB_HOVER_1','TAB_NORM_2','TAB_HOVER_2','TAB_NORM_3','TAB_HOVER_3','TAB_NORM_4','TAB_HOVER_4','LOC_ICON_NORM','LOC_ICON_HOVER','LOC_EXIT_NORM','LOC_EXIT_HOVER','LOC_MAP','LOC_NAV','LOC_BORD_TOP','LOC_BORD_BOTTOM','LOC_BORD_LEFT','LOC_BORD_RIGHT','LOC_BOX_TOP','LOC_BOX_LEFT','LOC_LABEL','TAB_HINT'];
hi := High(frmBitmaps);
for i := 0 to hi do
frmBitmaps[i] := LoadBitmap(ScriptPath + 'Bitmaps\' + bmpArr[i] + '.png');

frmMain := TForm.Create(nil);
with frmMain do
begin
SetBounds({L} 100, {T} 100, {W} 600, {H} 400);
//Position := poScreenCenter;
BorderStyle := bsNone;
end;

time := TTimer.Create(frmMain);
time.ONTIMER := @TimerTabClick;
time.INTERVAL := 10;
time.ENABLED := false;

xy := [Point(0,0), Point(575,7), Point(557,7), Point(7,69), Point(81,69), Point(390,100), Point(440,100), Point(490,100), Point(540,100), Point(179,204), Point(-300,0), Point(369,209), Point(475,7), Point(0,0), Point(0,393), Point(0,7), Point(593,7), Point(Round( 300 / 7.234 + 376), 216), Point(Round( 300 / 7.234 + 376), 216 + 1), Point(Round( 300 / 7.234 + 376) + 83, 216 + 1), Point(Round( 300 / 7.234 + 376), 216 + 1 + 54), Point(156,250), Point(208,379)];
wh := [Point(600,400), Point(18,18), Point(18,18), Point(74,22), Point(74,22), Point(50,290), Point(50,290), Point(50,290), Point(50,290), Point(40,41), Point(1454,1165), Point(215,175), Point(119,22), Point(600,7), Point(600,7), Point(7,386), Point(7,386), Point(83, 1), Point(1,55), Point(1,55), Point(83,1), Point(87,11), Point(174,10)];
visibl := [true, true, true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, true, true];
consts := [BGND, X_NORM, Q_NORM, LOAD_TAB_NORM,SAVE_TAB_NORM,TAB_NORM_1, TAB_NORM_2, TAB_NORM_3, TAB_NORM_4, LOC_ICON_NORM, LOC_MAP, LOC_NAV, LOC_EXIT_NORM, LOC_BORD_TOP, LOC_BORD_BOTTOM, LOC_BORD_LEFT, LOC_BORD_RIGHT, LOC_BOX_TOP, LOC_BOX_LEFT, LOC_BOX_LEFT, LOC_BOX_TOP, LOC_LABEL, TAB_HINT];
for Image := 0 to IMG_COUNT - 1 do
begin
tImages[Image] := TImage.Create(frmMain);
with tImages[Image] do
begin
Parent := frmMain;
SetBounds(xy[Image].x, xy[Image].y, wh[Image].x, wh[Image].y);
bmp := frmBitmaps[consts[image]];
OnMouseMove := @MouseMoved;
ONMOUSEDOWN := @OnMouseDown;
OnClick := @OnClickEvents;
isActiveImage[Image] := False;
if (Image > IMG_TAB_NORM_1) and (Image < IMG_TAB_NORM_4) then
isLeftTab[Image] := false;
visible := Visibl[Image];
end;
DrawBitmap(bmp, tImages[Image].canvas, 0, 0);
end;

isActivePanel[Panel_1] := True;
for i := 0 to high(IsActivePanel) do
isActivePanel[i] := False;

for i := low(panels) to high(panels) do
begin
panels[i] := TPanel.Create(frmMain);
panels[i].parent := frmMain;
panels[i].SetBounds(tImages[i].left + tImages[i].width,tImages[i].top, 0, tImages[i].height);
end;
end;

procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;

procedure ShowFormModal;
begin
frmMain.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;

begin
try
SafeInitForm;
SafeShowFormModal;
finally
time.ENABLED := false;
time.Free;
frmMain.Free;
except
Writeln(ExceptionToString(ExceptionType, ExceptionParam));
end;
end.


and without it:
program MSIForm;

const


PANEL_COUNT = 5;
PANEL_1 = 0;
PANEL_2 = 1;
PANEL_3 = 2;
PANEL_4 = 3;
PANEL_5 = 4;


IMG_COUNT = 23;
// Used in frmMain
IMG_BGND = 0;
IMG_X_NORM = 1;
IMG_Q_NORM = 2;
IMG_LOAD_TAB_NORM = 3;
IMG_SAVE_TAB_NORM = 4;
IMG_TAB_NORM_1 = 5;
IMG_TAB_NORM_2 = 6;
IMG_TAB_NORM_3 = 7;
IMG_TAB_NORM_4 = 8;

IMG_LOC_ICON_NORM = 9;
IMG_LOC_EXIT_NORM = 10;
IMG_LOC_MAP = 11;
IMG_LOC_NAV = 12;
IMG_LOC_BORD_TOP = 13;
IMG_LOC_BORD_BOTTOM = 14;
IMG_LOC_BORD_LEFT = 15;
IMG_LOC_BORD_RIGHT = 16;
IMG_LOC_BOX_TOP = 17;
IMG_LOC_BOX_LEFT = 18;
IMG_LOC_BOX_RIGHT = 19;
IMG_LOC_BOX_BOTTOM = 20;

// Used in Panel 0 (Is also used for frmMain)
IMG_LOC_LABEL = 21;
IMG_TAB_HINT = 22;

// Used in Panel 1

// Used in Panel 2

// Used in Panel 3

// Used in Panel 4

BITMAP_COUNT = 31;
BGND = 0;
X_NORM = 1;
X_HOVER = 2;
Q_NORM = 3;
Q_HOVER = 4;
LOAD_TAB_NORM = 5;
LOAD_TAB_HOVER = 6;
SAVE_TAB_NORM = 7;
SAVE_TAB_HOVER = 8;
TAB_NORM_1 = 9;
TAB_HOVER_1 = 10;
TAB_NORM_2 = 11;
TAB_HOVER_2 = 12;
TAB_NORM_3 = 13;
TAB_HOVER_3 = 14;
TAB_NORM_4 = 15;
TAB_HOVER_4 = 16;
LOC_ICON_NORM = 17;
LOC_ICON_HOVER = 18;
LOC_EXIT_NORM = 19;
LOC_EXIT_HOVER = 20;
LOC_MAP = 21;
LOC_NAV = 22;
LOC_BORD_TOP = 23;
LOC_BORD_BOTTOM = 24;
LOC_BORD_LEFT = 25;
LOC_BORD_RIGHT = 26;
LOC_BOX_TOP = 27;
LOC_BOX_LEFT = 28;
LOC_LABEL = 29;
TAB_HINT = 30;

var
frmMain: TForm;
time: TTimer;

tImages: Array[0..IMG_COUNT - 1] of TImage;

frmBitmaps: Array [0..BITMAP_COUNT - 1] of Integer;

isActiveImage: Array[0..IMG_COUNT - 1] of Boolean;
isLeftTab: Array[IMG_TAB_NORM_1..IMG_TAB_NORM_4] of Boolean;
isActivePanel: Array[0..PANEL_COUNT - 1] of Boolean;

MapDragStartX, MapDragStartY: Integer;


panels: array [IMG_TAB_NORM_1..IMG_TAB_NORM_4] of TPanel;


procedure OutsideBox(l,t,r,b, obj: integer);
begin
if tImages[obj].Left > l then
tImages[obj].Left := l;
if tImages[obj].Top > t then
tImages[obj].Top := t;
if tImages[obj].Left < r then
tImages[obj].Left := r;
if tImages[obj].Top < b then
tImages[obj].Top := b;
end;

procedure OnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
BoundL, BoundT: Extended;
begin
case sender of
tImages[IMG_LOC_MAP]:
begin
MapDragStartX := x;
MapDragStartY := y;
end;
tImages[IMG_LOC_NAV]:
begin
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x + (x - left), {T} y + (y - top), {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

OutsideBox(0,0,-345, -354, IMG_LOC_MAP);
end;
end;
end;

var sended: Tobject;
accel, move: integer;
cons: array [IMG_TAB_NORM_1..IMG_TAB_NORM_4] of integer;
procedure TimerTabClick(Sender: TObject);
var
senderTab, i, CurrentPanel, e, temp, d, top, bottom: Integer;
truth: boolean;
begin
for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_4 do
if (Sended = tImages[i]) then
senderTab := i;

if isLeftTab[senderTab] then
begin
d := 1
top := IMG_TAB_NORM_4
bottom := senderTab
end else
begin
d := -1;
top := senderTab
bottom := IMG_TAB_NORM_1
end;
truth := isLeftTab[senderTab];

for i := bottom to top do
if isLeftTab[i] = truth then
begin
if move = 0 then
for e := bottom to top do
cons[e] := tImages[e].Left;
if temp = 0 then
begin
accel := accel + 2;
move := move + accel;
end;
tImages[i].Left := tImages[i].Left + accel * d;
temp := 1;
end;
if move >= 380 then
begin
for e := bottom to top do
if isLeftTab[e] = truth then
begin
tImages[e].Left := cons[e] + 380 * d;
isLeftTab[e] := not truth;
end;
move := 0;
time.ENABLED := false;
end;
if truth then
CurrentPanel := sendertab - IMG_TAB_NORM_1
else
CurrentPanel := sendertab - IMG_TAB_NORM_1 + 1;
for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_4 do
begin
if i = currentPanel then
begin
panels[i].left := panels[i].left + accel * d;
panels[i].width := panels[i].width - accel * d;
end else
if panels[i].width <> 0 then
begin
if not isLeftTab[i] = truth then
panels[i].width := 0;
panels[i].left := panels[i].left - accel * d;
panels[i].width := panels[i].width + accel * d;
end;
end;

for i := PANEL_1 to PANEL_5 do
isActivePanel[i] := i = CurrentPanel;

//WriteLn(CurrentPanel);

for i := IMG_LOC_ICON_NORM to IMG_TAB_HINT do
tImages[i].Visible := isActivePanel[PANEL_1];
end;

procedure TabClick(Sender: TObject);
begin
if not time.ENABLED then
begin
accel := 0;
time.enabled := not time.enabled;
sended := Sender;
end;
end;

procedure LocViewer(Sender: TObject);
var i: Integer;
am: TintegerArray;
tru: boolean;
begin
am := [IMG_LOC_ICON_NORM, IMG_TAB_HINT, IMG_LOC_LABEL];
case Sender of
tImages[IMG_LOC_ICON_NORM]: tru := true;
tImages[IMG_LOC_EXIT_NORM]: tru := false;
end;

for i := IMG_LOC_EXIT_NORM to IMG_LOC_BOX_BOTTOM do
tImages[i].Visible := Tru;

for i := 0 to high(am) do
tImages[i].Visible := not tru;
end;

procedure Clicked(Sender: TObject);
var
i: Integer;
begin
for i := 0 to BITMAP_COUNT - 1 do
FreeBitmap(frmBitmaps[i]);
frmMain.ModalResult := mrOk;
end;

procedure MouseMoved(Sender: TObject; Shift: TShiftState; x, y: Integer);
var
hi, i, bmp, xdif, ydif, h: Integer;
BoundL, BoundT: Extended;
imgSwap, bmpArr, imgArr: Array of Integer;
begin
bmpArr := [ X_NORM, Q_NORM, LOAD_TAB_NORM,
SAVE_TAB_NORM, TAB_NORM_1, TAB_NORM_2,
TAB_NORM_3, TAB_NORM_4, LOC_ICON_NORM, LOC_EXIT_NORM ]

imgArr := [ IMG_X_NORM, IMG_Q_NORM, IMG_LOAD_TAB_NORM,
IMG_SAVE_TAB_NORM, IMG_TAB_NORM_1, IMG_TAB_NORM_2,
IMG_TAB_NORM_3, IMG_TAB_NORM_4, IMG_LOC_ICON_NORM, IMG_LOC_EXIT_NORM ]
hi := High(bmpArr);
case Sender of
tImages[IMG_BGND], tImages[IMG_LOC_MAP]:
begin
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;

bmp := frmBitmaps[bmpArr[i]];
DrawBitmap(bmp,tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;
end;
for h := 0 to hi do
case Sender of
tImages[imgArr[h]]:
begin
imgSwap := [imgArr[h], frmBitmaps[bmpArr[h] + 1]];
if not (isActiveImage[imgSwap[0]]) then
begin
DrawBitmap(imgSwap[1],tImages[imgSwap[0]].Canvas,0,0);
isActiveImage[imgSwap[0]] := True;
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;
if (i = imgSwap[0] - 1) then
Continue;
if imgSwap[0] = IMG_LOC_EXIT_NORM then
if (i = imgSwap[0] - 2) then
Continue;
if imgSwap[0] = IMG_LOC_ICON_NORM then
if (i = imgSwap[0] - 12) then
Continue;
bmp := frmBitmaps[bmpArr[i]];
DrawBitmap(bmp, tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;
end;
end;
case sender of
tImages[IMG_LOC_MAP]:
begin
if not IsMouseButtonDown(1) then exit;
xdif := x - MapDragStartX;
ydif := y - MapDragStartY;
tImages[IMG_LOC_MAP].Left := tImages[IMG_LOC_MAP].Left + xdif;
tImages[IMG_LOC_MAP].Top := tImages[IMG_LOC_MAP].Top + ydif;

OutsideBox(0,0,-854, -765, IMG_LOC_MAP);

BoundL := -tImages[IMG_LOC_MAP].Left / 7.234 + 376;
BoundT := -tImages[IMG_LOC_MAP].Top / 7.234 + 216;


with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} Round(BoundL), {T} Round(BoundT), {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);
end;
tImages[IMG_LOC_NAV]:
begin
if not IsMouseButtonDown(1) then exit;
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x - 55 - 100, {T} y - 40 - 100, {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

OutsideBox(0, 0, -854, -765, IMG_LOC_MAP);
end;
end;
end;

procedure OnClickEvents(Sender: TObject);
begin
case Sender of
tImages[IMG_X_NORM]: Clicked(Sender);
tImages[IMG_TAB_NORM_1], tImages[IMG_TAB_NORM_2],tImages[IMG_TAB_NORM_3], tImages[IMG_TAB_NORM_4]: TabClick(Sender);
tImages[IMG_LOC_ICON_NORM], tImages[IMG_LOC_EXIT_NORM]: LocViewer(Sender);
end;
end;

procedure InitForm;
var
Image, bmp, hi, i: Integer;
consts: TintegerArray;
bmpArr: TStringArray;
xy, wh: TPointArray;
visibl: TBoolArray;
begin
bmpArr := ['BGND','X_NORM','X_HOVER','Q_NORM','Q_HOVER','LOAD_TAB_NORM','LOAD_TAB_HOVER','SAVE_TAB_NORM','SAVE_TAB_HOVER','TAB_NORM_1','TAB_HOVER_1','TAB_NORM_2','TAB_HOVER_2','TAB_NORM_3','TAB_HOVER_3','TAB_NORM_4','TAB_HOVER_4','LOC_ICON_NORM','LOC_ICON_HOVER','LOC_EXIT_NORM','LOC_EXIT_HOVER','LOC_MAP','LOC_NAV','LOC_BORD_TOP','LOC_BORD_BOTTOM','LOC_BORD_LEFT','LOC_BORD_RIGHT','LOC_BOX_TOP','LOC_BOX_LEFT','LOC_LABEL','TAB_HINT'];
hi := High(frmBitmaps);
for i := 0 to hi do
frmBitmaps[i] := LoadBitmap(ScriptPath + 'Bitmaps\' + bmpArr[i] + '.png');

frmMain := TForm.Create(nil);
with frmMain do
begin
SetBounds({L} 100, {T} 100, {W} 600, {H} 400);
//Position := poScreenCenter;
BorderStyle := bsNone;
end;

time := TTimer.Create(frmMain);
time.ONTIMER := @TimerTabClick;
time.INTERVAL := 10;
time.ENABLED := false;

for Image := 0 to IMG_TAB_HINT do
begin
tImages[Image] := TImage.Create(frmMain);
with tImages[Image] do
begin
Parent := frmMain;
case Image of
IMG_BGND:
begin
SetBounds({L} 0, {T} 0, {W} 600, {H} 400);
bmp := frmBitmaps[BGND];
OnMouseMove := @MouseMoved;
isActiveImage[BGND] := False;
end;

IMG_X_NORM:
begin
SetBounds({L} 575, {T} 7, {W} 18, {H} 18);
bmp := frmBitmaps[X_NORM];
OnClick := @Clicked;
OnMouseMove := @MouseMoved;
isActiveImage[IMG_X_NORM] := False;
end;

IMG_Q_NORM:
begin
SetBounds({L} 557, {T} 7, {W} 18, {H} 18);
bmp := frmBitmaps[Q_NORM];
OnMouseMove := @MouseMoved;
isActiveImage[IMG_Q_NORM] := False;
end;

IMG_LOAD_TAB_NORM:
begin
SetBounds({L} 7, {T} 69, {W} 74, {H} 22);
bmp := frmBitmaps[LOAD_TAB_NORM];
OnMouseMove := @MouseMoved;
isActiveImage[IMG_LOAD_TAB_NORM] := False;
end;

IMG_SAVE_TAB_NORM:
begin
SetBounds({L} 81, {T} 69, {W} 74, {H} 22);
bmp := frmBitmaps[SAVE_TAB_NORM];
OnMouseMove := @MouseMoved;
isActiveImage[IMG_SAVE_TAB_NORM] := False;
end;

IMG_TAB_NORM_1:
begin
SetBounds({L} 390, {T} 100, {W} 50, {H} 290);
bmp := frmBitmaps[TAB_NORM_1];
OnMouseMove := @MouseMoved;
OnClick := @TabClick;
isActiveImage[IMG_TAB_NORM_1] := False;
isLeftTab[IMG_TAB_NORM_1] := False;
end;

IMG_TAB_NORM_2:
begin
SetBounds({L} 440, {T} 100, {W} 50, {H} 290);
bmp := frmBitmaps[TAB_NORM_2];
OnMouseMove := @MouseMoved;
OnClick := @TabClick;
isActiveImage[IMG_TAB_NORM_2] := False;
isLeftTab[IMG_TAB_NORM_1] := False;
end;

IMG_TAB_NORM_3:
begin
SetBounds({L} 490, {T} 100, {W} 50, {H} 290);
bmp := frmBitmaps[TAB_NORM_3];
OnMouseMove := @MouseMoved;
OnClick := @TabClick;
isActiveImage[BGND] := False;
isLeftTab[IMG_TAB_NORM_1] := False;
end;

IMG_TAB_NORM_4:
begin
SetBounds({L} 540, {T} 100, {W} 50, {H} 290);
bmp := frmBitmaps[TAB_NORM_4];
OnMouseMove := @MouseMoved;
OnClick := @TabClick;
isActiveImage[IMG_TAB_NORM_4] := False;
isLeftTab[IMG_TAB_NORM_1] := False;
end;

IMG_LOC_ICON_NORM:
begin
SetBounds({L} 179, {T} 204, {W} 40, {H} 41);
bmp := frmBitmaps[LOC_ICON_NORM];
OnClick := @LocViewer;
OnMouseMove := @MouseMoved;
isActiveImage[IMG_LOC_ICON_NORM] := False;
end;


// Location Viewer

IMG_LOC_MAP:
begin
SetBounds({L} -300, {T} 0, {W} 1454, {H} 1165);
bmp := frmBitmaps[LOC_MAP];
ONMOUSEDOWN := @OnMouseDown;
OnMouseMove := @MouseMoved;
isActiveImage[IMG_LOC_MAP] := False;
Visible := False;
end;

IMG_LOC_NAV:
begin
SetBounds({L} 369, {T} 209, {W} 215, {H} 175);
bmp := frmBitmaps[LOC_NAV];
ONMOUSEDOWN := @OnMouseDown;
OnMouseMove := @MouseMoved;
isActiveImage[IMG_LOC_NAV] := False;
Visible := False;
end;

IMG_LOC_EXIT_NORM:
begin
SetBounds({L} 475, {T} 7, {W} 119, {H} 22);
bmp := frmBitmaps[LOC_EXIT_NORM];
OnClick := @LocViewer;
OnMouseMove := @MouseMoved;
isActiveImage[IMG_LOC_MAP] := False;
Visible := False;
end;

IMG_LOC_BORD_TOP:
begin
SetBounds({L} 0, {T} 0, {W} 600, {H} 7);
bmp := frmBitmaps[LOC_BORD_TOP];
isActiveImage[IMG_LOC_BORD_TOP] := False;
Visible := False;
end;

IMG_LOC_BORD_BOTTOM:
begin
SetBounds({L} 0, {T} 393, {W} 600, {H} 7);
bmp := frmBitmaps[LOC_BORD_BOTTOM];
isActiveImage[IMG_LOC_BORD_BOTTOM] := False;
Visible := False;
end;

IMG_LOC_BORD_LEFT:
begin
SetBounds({L} 0, {T} 7, {W} 7, {H} 386);
bmp := frmBitmaps[LOC_BORD_LEFT];
isActiveImage[IMG_LOC_BORD_LEFT] := False;
Visible := False;
end;

IMG_LOC_BORD_RIGHT:
begin
SetBounds({L} 593, {T} 7, {W} 7, {H} 386);
bmp := frmBitmaps[LOC_BORD_RIGHT];
isActiveImage[IMG_LOC_BORD_RIGHT] := False;
Visible := False;
end;

IMG_LOC_BOX_TOP:
begin
SetBounds({L} Round(-tImages[IMG_LOC_MAP].Left / 7.234 + 376), {T} Round(-tImages[IMG_LOC_MAP].Top / 7.234 + 216), {W} 83, {H} 1);
bmp := frmBitmaps[LOC_BOX_TOP];
isActiveImage[IMG_LOC_BOX_TOP] := False;
Visible := False;
end;

IMG_LOC_BOX_LEFT:
begin
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
bmp := frmBitmaps[LOC_BOX_LEFT];
isActiveImage[IMG_LOC_BOX_LEFT] := False;
Visible := False;
end;

IMG_LOC_BOX_RIGHT:
begin
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
bmp := frmBitmaps[LOC_BOX_LEFT];
isActiveImage[IMG_LOC_BOX_RIGHT] := False;
Visible := False;
end;

IMG_LOC_BOX_BOTTOM:
begin
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);
bmp := frmBitmaps[LOC_BOX_TOP];
isActiveImage[IMG_LOC_BOX_BOTTOM] := False;
Visible := False;
end;

IMG_LOC_LABEL:
begin
SetBounds({L} 156, {T} 250, {W} 87, {H} 11);
bmp := frmBitmaps[LOC_LABEL];
isActiveImage[IMG_LOC_LABEL] := False;
Visible := True;
end;

IMG_TAB_HINT:
begin
SetBounds({L} 208, {T} 379, {W} 174, {H} 10);
bmp := frmBitmaps[TAB_HINT];
isActiveImage[IMG_TAB_HINT] := False;
Visible := True;
end;

end;
end;
DrawBitmap(bmp, tImages[Image].canvas, 0, 0);
end;

isActivePanel[Panel_1] := True;
for i := 0 to high(IsActivePanel) do
isActivePanel[i] := False;

for i := low(panels) to high(panels) do
begin
panels[i] := TPanel.Create(frmMain);
panels[i].parent := frmMain;
panels[i].SetBounds(tImages[i].left + tImages[i].width,tImages[i].top, 0, tImages[i].height);
end;
end;

procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;

procedure ShowFormModal;
begin
frmMain.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;

begin
try
SafeInitForm;
SafeShowFormModal;
finally
time.ENABLED := false;
time.Free;
frmMain.Free;
except
Writeln(ExceptionToString(ExceptionType, ExceptionParam));
end;
end.

They both work somewhat. But without my shortening, the map works as advertised, though you can't get out of the form once you're in it because it doesn't pop up the exit button. With mine it gets all screwed up but you can click the map to get out :p. And with both, when you click the first tab when it is on the left, it goes into the map.

Other than all of that, it works :)

EDIT: but i think the way the panel stuff is being done at the moment is a bit silly. Once this is all fixed, I think the panel clicking should be fixed. I don't know if anyone else agrees, but when you click a panel, i think, it should always move to the same space. Right now it doesn't and that sort of hinders my panel idea.

After that's fixed, switching to actual panels is next (because i think my problems with the panels may be being caused by the above problem). Right now my tests have been done on actual TPanels, but it should work the same on TImages. So, then the location bits and whatnot can all be moved to be separate from the actual form loading, which should make the kind of problems that are happening right now (the logic of the form being muddled by a specific panel's logic) happen less.

I don't know if you agree, but i think that the location thing should be on an actual panel, like in between the tabs rather than covering everything like it does now. I think it would make it easier to code because you wouldn't have to have all this showing and hiding logic, plus it makes the form more consistent. If not, then I would suggest adding a hidden panel to put the actual map and such on, and keeping it separate from the panel that holds the button to get to the map.

and finally, i didn't get any feedback about my mock up of the player declarations. I dunno if I could even get it to work well, but i like the concept, and i think the next and back buttons that I had added on the bottom at least would make it more apparent to the user what they're supposed to do to navigate the form.


I don't have time to reply properly dan but I agree with the point about there being a tab on the left to start with. I will have to make thinner tab images which I will either do tonight or after the weekend (i'm going to someones 50th.)

+ You are going the right way by shortening it. I have an idea why the loc viewer is not showing.

Sorry for the lack of time to make a proper reply.

Sir R. M8gic1an

2010-07-02 15:37:35

From: Dan Cardin

and finally, i didn't get any feedback about my mock up of the player declarations. I dunno if I could even get it to work well, but i like the concept, and i think the next and back buttons that I had added on the bottom at least would make it more apparent to the user what they're supposed to do to navigate the form.


I didn't see these anywhere..?

~RM

ReadySteadyGo

2010-07-02 18:05:10

Rasta:

From: Dan Cardin
Declare players
Player specific settings.
those are what i think would look nice. You might run into problems of a limit to the number of players you can display, but with some creative arrow button making or form resizing, or button resizing, it might still work.

EDIT: the first picture isnt showing up for me, so http://i48.tinypic.com/28245qx.jpg

Sir R. M8gic1an

2010-07-02 20:34:48

Oh, that. Quite honestly, I find it ugly.

First thing to consider, is that you'll have two more 'tabs' in there, therefore you'll have less space. I also find the names to be too small atm (font size).

The names on the right don't make sense to me.. is that intend to be players that aren't set up yet? If so, how would you know the player names?

Also, rather than the arrow, I'd have the name showing up in a different color (eg yellow) and if a player has any missing info, red.

'Back' and 'Next' I guess is for the tabs. Considering that on tab #1 you say 'click the tabs to go to the next one', it doesn't make too much sense to have those buttons. With these changes done, you should have enough space to make a proper player form.

If not, you can make a '2 page' player form, meaning a 'sub-tab'.
(= new player, first setup page, second setup page)
The first one would probably have the basics such as player name and so on, while te second would have the MSI only stuff such as choosing the different script.

For choosing the scripts, I'd suggest you just loop through the scripts array to fetch their names and then display it in some stylish, (or simple) way.

Back to the players list, maybe change the font to green when the player is properly set up.

So relation to the pictures you posted,

on #1 I'd move the ['+', ' KJSA231' 'NEW PLAYER'] to the left, (make sure both the '+' and the 'NEW PLAYER' trigger the @NewPlayer event) and I would center and put to top Declare Players.

[php]
MSI Form
Tab 1: Welcome
Tab 2: DeclarePlayers
Tab 3: Script Setup (anti-ban rate, auto-responder, whatever)
Tab 4: Thank you & link to useful stuff & Start Script
[/php]

Great job btw :)

~RM

Dan Cardin

2010-07-02 21:56:46

First thing to consider, is that you'll have two more 'tabs' in there, therefore you'll have less space. I also find the names to be too small atm (font size).
if you mean the two tabs that are in the form now, they would be replacing those two tabs. they meaning the names and whatnot that I have where those tabs would have been. If that's not what you mean, then you'd have less space than you do now anyway, and the form will need to get wider anyway.

The names on the right don't make sense to me.. is that intend to be players that aren't set up yet? If so, how would you know the player names?
Well the first picture is where you add players and whatnot.

When you click next on the first picture, after adding however many people, you'll arrive at the 2nd picture. The names on the right will match up with the ones that you created on the left, and when you click on one of those names on the right, it will slide over to the left, and change to the arrow, to indicate which one you've selected. Then you can do player specific settings.

The next and back buttons were because i broke the tab up into the players that had been made, and you would need something to click on to go past the player settings pages.

Your idea on the "sub tab" was basically what this all is, but it puts the players names themselves as the visual representation of the sub tabs so that you dont have the overall tabs…then the tabs for each player in one of those tabs…then the sub tabs/extendedness for each player for the settings.

Nava2

2010-07-02 23:56:03

That arrow looks like crap. :<

Just change the colour of the tab. :)

Dan Cardin

2010-07-03 09:34:37

It was a very quick mockup made to show the general concept -.- :p.

EDIT: I win. I fixed all the errors I created :).
program MSIForm;

const


PANEL_COUNT = 5;
PANEL_1 = 0;
PANEL_2 = 1;
PANEL_3 = 2;
PANEL_4 = 3;
PANEL_5 = 4;


IMG_COUNT = 23;
// Used in frmMain
IMG_BGND = 0;
IMG_X_NORM = 1;
IMG_Q_NORM = 2;
IMG_LOAD_TAB_NORM = 3;
IMG_SAVE_TAB_NORM = 4;
IMG_TAB_NORM_1 = 5;
IMG_TAB_NORM_2 = 6;
IMG_TAB_NORM_3 = 7;
IMG_TAB_NORM_4 = 8;

IMG_LOC_ICON_NORM = 9;
IMG_LOC_EXIT_NORM = 10;
IMG_LOC_MAP = 11;
IMG_LOC_NAV = 12;
IMG_LOC_BORD_TOP = 13;
IMG_LOC_BORD_BOTTOM = 14;
IMG_LOC_BORD_LEFT = 15;
IMG_LOC_BORD_RIGHT = 16;
IMG_LOC_BOX_TOP = 17;
IMG_LOC_BOX_LEFT = 18;
IMG_LOC_BOX_RIGHT = 19;
IMG_LOC_BOX_BOTTOM = 20;

// Used in Panel 0 (Is also used for frmMain)
IMG_LOC_LABEL = 21;
IMG_TAB_HINT = 22;

// Used in Panel 1

// Used in Panel 2

// Used in Panel 3

// Used in Panel 4

BITMAP_COUNT = 31;
BGND = 0;
X_NORM = 1;
X_HOVER = 2;
Q_NORM = 3;
Q_HOVER = 4;
LOAD_TAB_NORM = 5;
LOAD_TAB_HOVER = 6;
SAVE_TAB_NORM = 7;
SAVE_TAB_HOVER = 8;
TAB_NORM_1 = 9;
TAB_HOVER_1 = 10;
TAB_NORM_2 = 11;
TAB_HOVER_2 = 12;
TAB_NORM_3 = 13;
TAB_HOVER_3 = 14;
TAB_NORM_4 = 15;
TAB_HOVER_4 = 16;
LOC_ICON_NORM = 17;
LOC_ICON_HOVER = 18;
LOC_EXIT_NORM = 19;
LOC_EXIT_HOVER = 20;
LOC_MAP = 21;
LOC_NAV = 22;
LOC_BORD_TOP = 23;
LOC_BORD_BOTTOM = 24;
LOC_BORD_LEFT = 25;
LOC_BORD_RIGHT = 26;
LOC_BOX_TOP = 27;
LOC_BOX_LEFT = 28;
LOC_LABEL = 29;
TAB_HINT = 30;

var
frmMain: TForm;
time: TTimer;

tImages: Array[0..IMG_COUNT - 1] of TImage;

frmBitmaps: Array [0..BITMAP_COUNT - 1] of Integer;

isActiveImage: Array[0..IMG_COUNT - 1] of Boolean;
isLeftTab: Array[IMG_TAB_NORM_1..IMG_TAB_NORM_4] of Boolean;
isActivePanel: Array[0..PANEL_COUNT - 1] of Boolean;

MapDragStartX, MapDragStartY: Integer;


panels: array [IMG_TAB_NORM_1..IMG_TAB_NORM_4] of TPanel;


procedure OutsideBox(l,t,r,b, obj: integer);
begin
if tImages[obj].Left > l then
tImages[obj].Left := l;
if tImages[obj].Top > t then
tImages[obj].Top := t;
if tImages[obj].Left < r then
tImages[obj].Left := r;
if tImages[obj].Top < b then
tImages[obj].Top := b;
end;

procedure OnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
BoundL, BoundT: Extended;
begin
case sender of
tImages[IMG_LOC_MAP]:
begin
MapDragStartX := x;
MapDragStartY := y;
end;
tImages[IMG_LOC_NAV]:
begin
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x + (x - left), {T} y + (y - top), {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

OutsideBox(0,0,-345, -354, IMG_LOC_MAP);
end;
end;
end;

var sended: Tobject;
accel, move: integer;
cons: array [IMG_TAB_NORM_1..IMG_TAB_NORM_4] of integer;
procedure TimerTabClick(Sender: TObject);
var
senderTab, i, CurrentPanel, e, temp, d, top, bottom: Integer;
truth: boolean;
am: TIntegerArray;
begin
for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_4 do
if (Sended = tImages[i]) then
senderTab := i;

if isLeftTab[senderTab] then
begin
d := 1
top := IMG_TAB_NORM_4
bottom := senderTab
end else
begin
d := -1;
top := senderTab
bottom := IMG_TAB_NORM_1
end;
truth := isLeftTab[senderTab];

for i := bottom to top do
if isLeftTab[i] = truth then
begin
if move = 0 then
for e := bottom to top do
cons[e] := tImages[e].Left;
if temp = 0 then
begin
accel := accel + 2;
move := move + accel;
end;
tImages[i].Left := tImages[i].Left + accel * d;
temp := 1;
end;
if move >= 380 then
begin
for e := bottom to top do
if isLeftTab[e] = truth then
begin
tImages[e].Left := cons[e] + 380 * d;
isLeftTab[e] := not truth;
end;
move := 0;
time.ENABLED := false;
end;
if truth then
CurrentPanel := sendertab - IMG_TAB_NORM_1
else
CurrentPanel := sendertab - IMG_TAB_NORM_1 + 1;
for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_4 do
begin
if i = currentPanel then
begin
panels[i].left := panels[i].left + accel * d;
panels[i].width := panels[i].width - accel * d;
end else
if panels[i].width <> 0 then
begin
if not isLeftTab[i] = truth then
panels[i].width := 0;
panels[i].left := panels[i].left - accel * d;
panels[i].width := panels[i].width + accel * d;
end;
end;

for i := PANEL_1 to PANEL_5 do
isActivePanel[i] := i = CurrentPanel;

//WriteLn(CurrentPanel);

am := [IMG_LOC_ICON_NORM,IMG_LOC_LABEL,IMG_TAB_HINT];
for i := 0 to high(am) do
tImages[am[i]].Visible := isActivePanel[PANEL_1];
end;

procedure TabClick(Sender: TObject);
begin
if not time.ENABLED then
begin
accel := 0;
time.enabled := not time.enabled;
sended := Sender;
end;
end;

procedure LocViewer(Sender: TObject);
var i: Integer;
am: TintegerArray;
tru: boolean;
begin
am := [IMG_LOC_ICON_NORM, IMG_TAB_HINT, IMG_LOC_LABEL];
case Sender of
tImages[IMG_LOC_ICON_NORM]: tru := true;
tImages[IMG_LOC_EXIT_NORM]: tru := false;
end;

for i := IMG_LOC_EXIT_NORM to IMG_LOC_BOX_BOTTOM do
tImages[i].Visible := Tru;

for i := 0 to high(am) do
tImages[am[i]].Visible := not tru;
end;

procedure Clicked(Sender: TObject);
var
i: Integer;
begin
for i := 0 to BITMAP_COUNT - 1 do
FreeBitmap(frmBitmaps[i]);
frmMain.ModalResult := mrOk;
end;

procedure MouseMoved(Sender: TObject; Shift: TShiftState; x, y: Integer);
var
hi, i, bmp, xdif, ydif, h: Integer;
BoundL, BoundT: Extended;
imgSwap, bmpArr, imgArr: Array of Integer;
begin
bmpArr := [ X_NORM, Q_NORM, LOAD_TAB_NORM,
SAVE_TAB_NORM, TAB_NORM_1, TAB_NORM_2,
TAB_NORM_3, TAB_NORM_4, LOC_ICON_NORM, LOC_EXIT_NORM ]

imgArr := [ IMG_X_NORM, IMG_Q_NORM, IMG_LOAD_TAB_NORM,
IMG_SAVE_TAB_NORM, IMG_TAB_NORM_1, IMG_TAB_NORM_2,
IMG_TAB_NORM_3, IMG_TAB_NORM_4, IMG_LOC_ICON_NORM, IMG_LOC_EXIT_NORM ]
hi := High(bmpArr);
case Sender of
tImages[IMG_BGND], tImages[IMG_LOC_MAP]:
begin
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;

bmp := frmBitmaps[bmpArr[i]];
DrawBitmap(bmp,tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;
end;
for h := 0 to hi do
case Sender of
tImages[imgArr[h]]:
begin
imgSwap := [imgArr[h], frmBitmaps[bmpArr[h] + 1]];
if not (isActiveImage[imgSwap[0]]) then
begin
DrawBitmap(imgSwap[1],tImages[imgSwap[0]].Canvas,0,0);
isActiveImage[imgSwap[0]] := True;
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;
if (i = imgSwap[0] - 1) then
Continue;
if imgSwap[0] = IMG_LOC_EXIT_NORM then
if (i = imgSwap[0] - 2) then
Continue;
if imgSwap[0] = IMG_LOC_ICON_NORM then
if (i = imgSwap[0] - 12) then
Continue;
bmp := frmBitmaps[bmpArr[i]];
DrawBitmap(bmp, tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;
end;
end;
case sender of
tImages[IMG_LOC_MAP]:
begin
if not IsMouseButtonDown(1) then exit;
xdif := x - MapDragStartX;
ydif := y - MapDragStartY;
tImages[IMG_LOC_MAP].Left := tImages[IMG_LOC_MAP].Left + xdif;
tImages[IMG_LOC_MAP].Top := tImages[IMG_LOC_MAP].Top + ydif;

OutsideBox(0,0,-854, -765, IMG_LOC_MAP);

BoundL := -tImages[IMG_LOC_MAP].Left / 7.234 + 376;
BoundT := -tImages[IMG_LOC_MAP].Top / 7.234 + 216;


with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} Round(BoundL), {T} Round(BoundT), {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);
end;
tImages[IMG_LOC_NAV]:
begin
if not IsMouseButtonDown(1) then exit;
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x - 55 - 100, {T} y - 40 - 100, {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

OutsideBox(0, 0, -854, -765, IMG_LOC_MAP);
end;
end;
end;

procedure OnClickEvents(Sender: TObject);
begin
case Sender of
tImages[IMG_X_NORM]: Clicked(Sender);
tImages[IMG_TAB_NORM_1], tImages[IMG_TAB_NORM_2],tImages[IMG_TAB_NORM_3], tImages[IMG_TAB_NORM_4]: TabClick(Sender);
tImages[IMG_LOC_ICON_NORM], tImages[IMG_LOC_EXIT_NORM]: LocViewer(Sender);
end;
end;

procedure InitForm;
var
Image, bmp, hi, i: Integer;
consts: TintegerArray;
bmpArr: TStringArray;
xy, wh: TPointArray;
visibl: TBoolArray;
begin
bmpArr := ['BGND','X_NORM','X_HOVER','Q_NORM','Q_HOVER','LOAD_TAB_NORM','LOAD_TAB_HOVER','SAVE_TAB_NORM','SAVE_TAB_HOVER','TAB_NORM_1','TAB_HOVER_1','TAB_NORM_2','TAB_HOVER_2','TAB_NORM_3','TAB_HOVER_3','TAB_NORM_4','TAB_HOVER_4','LOC_ICON_NORM','LOC_ICON_HOVER','LOC_EXIT_NORM','LOC_EXIT_HOVER','LOC_MAP','LOC_NAV','LOC_BORD_TOP','LOC_BORD_BOTTOM','LOC_BORD_LEFT','LOC_BORD_RIGHT','LOC_BOX_TOP','LOC_BOX_LEFT','LOC_LABEL','TAB_HINT'];
hi := High(frmBitmaps);
for i := 0 to hi do
frmBitmaps[i] := LoadBitmap(ScriptPath + 'Bitmaps\' + bmpArr[i] + '.png');

frmMain := TForm.Create(nil);
with frmMain do
begin
SetBounds({L} 100, {T} 100, {W} 600, {H} 400);
//Position := poScreenCenter;
BorderStyle := bsNone;
end;

time := TTimer.Create(frmMain);
time.ONTIMER := @TimerTabClick;
time.INTERVAL := 10;
time.ENABLED := false;

xy := [Point(0,0), Point(575,7), Point(557,7), Point(7,69), Point(81,69), Point(390,100), Point(440,100), Point(490,100), Point(540,100), Point(179,204), Point(475,7), Point(-300,0), Point(369,209), Point(0,0), Point(0,393), Point(0,7), Point(593,7), Point(Round( 300 / 7.234 + 376), 216), Point(Round( 300 / 7.234 + 376), 216 + 1), Point(Round( 300 / 7.234 + 376) + 83, 216 + 1), Point(Round( 300 / 7.234 + 376), 216 + 1 + 54), Point(156,250), Point(208,379)];
wh := [Point(600,400), Point(18,18), Point(18,18), Point(74,22), Point(74,22), Point(50,290), Point(50,290), Point(50,290), Point(50,290), Point(40,41), Point(119,22), Point(1454,1165), Point(215,175), Point(600,7), Point(600,7), Point(7,386), Point(7,386), Point(83, 1), Point(1,55), Point(1,55), Point(83,1), Point(87,11), Point(174,10)];
visibl := [true, true, true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, true, true];
consts := [BGND, X_NORM, Q_NORM, LOAD_TAB_NORM,SAVE_TAB_NORM,TAB_NORM_1, TAB_NORM_2, TAB_NORM_3, TAB_NORM_4, LOC_ICON_NORM, LOC_EXIT_NORM, LOC_MAP, LOC_NAV, LOC_BORD_TOP, LOC_BORD_BOTTOM, LOC_BORD_LEFT, LOC_BORD_RIGHT, LOC_BOX_TOP, LOC_BOX_LEFT, LOC_BOX_LEFT, LOC_BOX_TOP, LOC_LABEL, TAB_HINT];
for Image := 0 to IMG_COUNT - 1 do
begin
tImages[Image] := TImage.Create(frmMain);
with tImages[Image] do
begin
Parent := frmMain;
SetBounds(xy[Image].x, xy[Image].y, wh[Image].x, wh[Image].y);
bmp := frmBitmaps[consts[image]];
OnMouseMove := @MouseMoved;
ONMOUSEDOWN := @OnMouseDown;
OnClick := @OnClickEvents;
isActiveImage[Image] := False;
if (Image > IMG_TAB_NORM_1) and (Image < IMG_TAB_NORM_4) then
isLeftTab[Image] := false;
visible := Visibl[Image];
end;
DrawBitmap(bmp, tImages[Image].canvas, 0, 0);
end;
tImages[10].BringToFront;

isActivePanel[Panel_1] := True;
for i := 0 to high(IsActivePanel) do
isActivePanel[i] := False;

for i := low(panels) to high(panels) do
begin
panels[i] := TPanel.Create(frmMain);
panels[i].parent := frmMain;
panels[i].SetBounds(tImages[i].left + tImages[i].width,tImages[i].top, 0, tImages[i].height);
end;
end;

procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;

procedure ShowFormModal;
begin
frmMain.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;

begin
try
SafeInitForm;
SafeShowFormModal;
finally
time.ENABLED := false;
time.Free;
frmMain.Free;
except
Writeln(ExceptionToString(ExceptionType, ExceptionParam));
end;
end.

Sabzi

2010-07-03 10:28:10

Uhh, after trying your first version of the moving panels and this one, I have to say it's a big change.
It seems flawless.
Very nice.

jimmy_mac

2010-07-03 12:20:59

hey kids.
heres the psd of the logo.
http://www19.zippyshare.com/v/68062454/file.html

Dan Cardin

2010-07-03 20:26:14

what do you need a google email? [email]candardin@gmail.com[/email]

ok now.

-It was surprisingly simple to get it to always put the tab that you click in the same spot. All it took was a +1. So That's good.
-Made the animation simpler again. I guess it's more efficient since it's not doing unnecessary logic every loop through.
-Got rid of your panel constants because they don't really stand for anything. In this case, an array is better. With that, I'm kind of phasing out isActivePanel, because i don't think its really that needed. You can't have more than one active panel at a time, so i mean…an integer (senderTab) should suffice to say which panel is active at the moment.
-In the midst of getting panels to work. Made it a lot simpler than i was trying for before, and it almost works really well! It seems to do so at first, but then when you start clicking around in the middle ones it screws up. At the moment I don't know why.

program MSIForm;

const


{ PANEL_COUNT = 5;
PANEL_1 = 0;
PANEL_2 = 1;
PANEL_3 = 2;
PANEL_4 = 3;
PANEL_5 = 4; }


IMG_COUNT = 23;
// Used in frmMain
IMG_BGND = 0;
IMG_X_NORM = 1;
IMG_Q_NORM = 2;
IMG_LOAD_TAB_NORM = 3;
IMG_SAVE_TAB_NORM = 4;
IMG_TAB_NORM_1 = 5;
IMG_TAB_NORM_2 = 6;
IMG_TAB_NORM_3 = 7;
IMG_TAB_NORM_4 = 8;

IMG_LOC_ICON_NORM = 9;
IMG_LOC_EXIT_NORM = 10;
IMG_LOC_MAP = 11;
IMG_LOC_NAV = 12;
IMG_LOC_BORD_TOP = 13;
IMG_LOC_BORD_BOTTOM = 14;
IMG_LOC_BORD_LEFT = 15;
IMG_LOC_BORD_RIGHT = 16;
IMG_LOC_BOX_TOP = 17;
IMG_LOC_BOX_LEFT = 18;
IMG_LOC_BOX_RIGHT = 19;
IMG_LOC_BOX_BOTTOM = 20;

// Used in Panel 0 (Is also used for frmMain)
IMG_LOC_LABEL = 21;
IMG_TAB_HINT = 22;

// Used in Panel 1

// Used in Panel 2

// Used in Panel 3

// Used in Panel 4

BITMAP_COUNT = 31;
BGND = 0;
X_NORM = 1;
X_HOVER = 2;
Q_NORM = 3;
Q_HOVER = 4;
LOAD_TAB_NORM = 5;
LOAD_TAB_HOVER = 6;
SAVE_TAB_NORM = 7;
SAVE_TAB_HOVER = 8;
TAB_NORM_1 = 9;
TAB_HOVER_1 = 10;
TAB_NORM_2 = 11;
TAB_HOVER_2 = 12;
TAB_NORM_3 = 13;
TAB_HOVER_3 = 14;
TAB_NORM_4 = 15;
TAB_HOVER_4 = 16;
LOC_ICON_NORM = 17;
LOC_ICON_HOVER = 18;
LOC_EXIT_NORM = 19;
LOC_EXIT_HOVER = 20;
LOC_MAP = 21;
LOC_NAV = 22;
LOC_BORD_TOP = 23;
LOC_BORD_BOTTOM = 24;
LOC_BORD_LEFT = 25;
LOC_BORD_RIGHT = 26;
LOC_BOX_TOP = 27;
LOC_BOX_LEFT = 28;
LOC_LABEL = 29;
TAB_HINT = 30;

var
frmMain: TForm;
time: TTimer;

tImages: Array[0..IMG_COUNT - 1] of TImage;

frmBitmaps: Array [0..BITMAP_COUNT - 1] of Integer;

isActiveImage: Array[0..IMG_COUNT - 1] of Boolean;
isLeftTab: Array[IMG_TAB_NORM_1..IMG_TAB_NORM_4] of Boolean;
isActivePanel: Array[IMG_TAB_NORM_1..IMG_TAB_NORM_4] of Boolean;

MapDragStartX, MapDragStartY: Integer;


panels: array [IMG_TAB_NORM_1..IMG_TAB_NORM_4] of TPanel;


procedure OutsideBox(l,t,r,b, obj: integer);
begin
if tImages[obj].Left > l then
tImages[obj].Left := l;
if tImages[obj].Top > t then
tImages[obj].Top := t;
if tImages[obj].Left < r then
tImages[obj].Left := r;
if tImages[obj].Top < b then
tImages[obj].Top := b;
end;

procedure OnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
BoundL, BoundT: Extended;
begin
case sender of
tImages[IMG_LOC_MAP]:
begin
MapDragStartX := x;
MapDragStartY := y;
end;
tImages[IMG_LOC_NAV]:
begin
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x + (x - left), {T} y + (y - top), {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

OutsideBox(0,0,-345, -354, IMG_LOC_MAP);
end;
end;
end;

var
accel, move, senderTab, pan: integer;
cons: array [IMG_TAB_NORM_1..IMG_TAB_NORM_4] of integer;
procedure TimerTabClick(Sender: TObject);
var
i, e, d, top, bottom: Integer;
truth: boolean;
am: TIntegerArray;
begin
truth := isLeftTab[senderTab];
d := integer(truth)* 2 - 1;
if truth then
begin
top := IMG_TAB_NORM_4
bottom := senderTab + 1;
end else
begin
top := senderTab;
bottom := IMG_TAB_NORM_1
end;

if move = 0 then
for e := bottom to top do
cons[e] := tImages[e].Left;
accel := accel + 2;
move := move + accel;
for i := bottom to top do
if isLeftTab[i] = truth then
tImages[i].Left := tImages[i].Left + accel * d;
if move >= 380 then
begin
for e := bottom to top do
if isLeftTab[e] = truth then
begin
tImages[e].Left := cons[e] + 380 * d;
isLeftTab[e] := not truth;
end;
move := 0;
time.ENABLED := false;
end;

if pan < senderTab then
panels[pan].width := panels[pan].width + accel * d;
if pan > senderTab then
begin
panels[pan].left := panels[pan].left + accel * d;
panels[pan].width := panels[pan].width - accel * d;
end;

if pan > senderTab then
panels[senderTab].width := panels[senderTab].width + accel * d;
if pan < senderTab then
begin
panels[senderTab].left := panels[senderTab].left + accel * d;
panels[senderTab].width := panels[senderTab].width - accel * d;
end;

am := [IMG_LOC_ICON_NORM,IMG_LOC_LABEL,IMG_TAB_HINT];
for i := 0 to high(am) do
tImages[am[i]].Visible := isActivePanel[IMG_TAB_NORM_1];
end;

procedure TabClick(Sender: TObject);
var i: integer;
begin
if not time.ENABLED then
begin
accel := 0;
time.enabled := not time.enabled;
pan := senderTab;
isActivePanel[pan] := false;
for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_4 do
if (Sender = tImages[i]) then
senderTab := i;
isActivePanel[senderTab] := true;
end;
end;

procedure LocViewer(Sender: TObject);
var i: Integer;
am: TintegerArray;
tru: boolean;
begin
am := [IMG_LOC_ICON_NORM, IMG_TAB_HINT, IMG_LOC_LABEL];
case Sender of
tImages[IMG_LOC_ICON_NORM]: tru := true;
tImages[IMG_LOC_EXIT_NORM]: tru := false;
end;

for i := IMG_LOC_EXIT_NORM to IMG_LOC_BOX_BOTTOM do
tImages[i].Visible := Tru;

for i := 0 to high(am) do
tImages[am[i]].Visible := not tru;
end;

procedure Clicked(Sender: TObject);
var
i: Integer;
begin
for i := 0 to BITMAP_COUNT - 1 do
FreeBitmap(frmBitmaps[i]);
frmMain.ModalResult := mrOk;
end;

procedure MouseMoved(Sender: TObject; Shift: TShiftState; x, y: Integer);
var
hi, i, bmp, xdif, ydif, h: Integer;
BoundL, BoundT: Extended;
imgSwap, bmpArr, imgArr: Array of Integer;
begin
bmpArr := [ X_NORM, Q_NORM, LOAD_TAB_NORM,
SAVE_TAB_NORM, TAB_NORM_1, TAB_NORM_2,
TAB_NORM_3, TAB_NORM_4, LOC_ICON_NORM, LOC_EXIT_NORM ]

imgArr := [ IMG_X_NORM, IMG_Q_NORM, IMG_LOAD_TAB_NORM,
IMG_SAVE_TAB_NORM, IMG_TAB_NORM_1, IMG_TAB_NORM_2,
IMG_TAB_NORM_3, IMG_TAB_NORM_4, IMG_LOC_ICON_NORM, IMG_LOC_EXIT_NORM ]
hi := High(bmpArr);
case Sender of
tImages[IMG_BGND], tImages[IMG_LOC_MAP]:
begin
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;

bmp := frmBitmaps[bmpArr[i]];
DrawBitmap(bmp,tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;
end;
for h := 0 to hi do
case Sender of
tImages[imgArr[h]]:
begin
imgSwap := [imgArr[h], frmBitmaps[bmpArr[h] + 1]];
if not (isActiveImage[imgSwap[0]]) then
begin
DrawBitmap(imgSwap[1],tImages[imgSwap[0]].Canvas,0,0);
isActiveImage[imgSwap[0]] := True;
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;
if (i = imgSwap[0] - 1) then
Continue;
if imgSwap[0] = IMG_LOC_EXIT_NORM then
if (i = imgSwap[0] - 2) then
Continue;
if imgSwap[0] = IMG_LOC_ICON_NORM then
if (i = imgSwap[0] - 12) then
Continue;
bmp := frmBitmaps[bmpArr[i]];
DrawBitmap(bmp, tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;
end;
end;
case sender of
tImages[IMG_LOC_MAP]:
begin
if not IsMouseButtonDown(1) then exit;
xdif := x - MapDragStartX;
ydif := y - MapDragStartY;
tImages[IMG_LOC_MAP].Left := tImages[IMG_LOC_MAP].Left + xdif;
tImages[IMG_LOC_MAP].Top := tImages[IMG_LOC_MAP].Top + ydif;

OutsideBox(0,0,-854, -765, IMG_LOC_MAP);

BoundL := -tImages[IMG_LOC_MAP].Left / 7.234 + 376;
BoundT := -tImages[IMG_LOC_MAP].Top / 7.234 + 216;


with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} Round(BoundL), {T} Round(BoundT), {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);
end;
tImages[IMG_LOC_NAV]:
begin
if not IsMouseButtonDown(1) then exit;
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x - 55 - 100, {T} y - 40 - 100, {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

OutsideBox(0, 0, -854, -765, IMG_LOC_MAP);
end;
end;
end;

procedure OnClickEvents(Sender: TObject);
begin
case Sender of
tImages[IMG_X_NORM]: Clicked(Sender);
tImages[IMG_TAB_NORM_1], tImages[IMG_TAB_NORM_2],tImages[IMG_TAB_NORM_3], tImages[IMG_TAB_NORM_4]: TabClick(Sender);
tImages[IMG_LOC_ICON_NORM], tImages[IMG_LOC_EXIT_NORM]: LocViewer(Sender);
end;
end;

procedure InitForm;
var
Image, bmp, hi, i: Integer;
consts: TintegerArray;
bmpArr: TStringArray;
xy, wh: TPointArray;
visibl: TBoolArray;
begin
bmpArr := ['BGND','X_NORM','X_HOVER','Q_NORM','Q_HOVER','LOAD_TAB_NORM','LOAD_TAB_HOVER','SAVE_TAB_NORM','SAVE_TAB_HOVER','TAB_NORM_1','TAB_HOVER_1','TAB_NORM_2','TAB_HOVER_2','TAB_NORM_3','TAB_HOVER_3','TAB_NORM_4','TAB_HOVER_4','LOC_ICON_NORM','LOC_ICON_HOVER','LOC_EXIT_NORM','LOC_EXIT_HOVER','LOC_MAP','LOC_NAV','LOC_BORD_TOP','LOC_BORD_BOTTOM','LOC_BORD_LEFT','LOC_BORD_RIGHT','LOC_BOX_TOP','LOC_BOX_LEFT','LOC_LABEL','TAB_HINT'];
hi := High(frmBitmaps);
for i := 0 to hi do
frmBitmaps[i] := LoadBitmap(ScriptPath + 'Bitmaps\' + bmpArr[i] + '.png');

frmMain := TForm.Create(nil);
with frmMain do
begin
SetBounds({L} 100, {T} 100, {W} 600, {H} 400);
//Position := poScreenCenter;
BorderStyle := bsNone;
end;

time := TTimer.Create(frmMain);
time.ONTIMER := @TimerTabClick;
time.INTERVAL := 10;
time.ENABLED := false;

xy := [Point(0,0), Point(575,7), Point(557,7), Point(7,69), Point(81,69), Point(10{390},100), Point(440,100), Point(490,100), Point(540,100), Point(179,204), Point(475,7), Point(-300,0), Point(369,209), Point(0,0), Point(0,393), Point(0,7), Point(593,7), Point(Round( 300 / 7.234 + 376), 216), Point(Round( 300 / 7.234 + 376), 216 + 1), Point(Round( 300 / 7.234 + 376) + 83, 216 + 1), Point(Round( 300 / 7.234 + 376), 216 + 1 + 54), Point(156,250), Point(208,379)];
wh := [Point(600,400), Point(18,18), Point(18,18), Point(74,22), Point(74,22), Point(50,290), Point(50,290), Point(50,290), Point(50,290), Point(40,41), Point(119,22), Point(1454,1165), Point(215,175), Point(600,7), Point(600,7), Point(7,386), Point(7,386), Point(83, 1), Point(1,55), Point(1,55), Point(83,1), Point(87,11), Point(174,10)];
visibl := [true, true, true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, true, true];
consts := [BGND, X_NORM, Q_NORM, LOAD_TAB_NORM,SAVE_TAB_NORM,TAB_NORM_1, TAB_NORM_2, TAB_NORM_3, TAB_NORM_4, LOC_ICON_NORM, LOC_EXIT_NORM, LOC_MAP, LOC_NAV, LOC_BORD_TOP, LOC_BORD_BOTTOM, LOC_BORD_LEFT, LOC_BORD_RIGHT, LOC_BOX_TOP, LOC_BOX_LEFT, LOC_BOX_LEFT, LOC_BOX_TOP, LOC_LABEL, TAB_HINT];
for Image := 0 to IMG_COUNT - 1 do
begin
tImages[Image] := TImage.Create(frmMain);
with tImages[Image] do
begin
Parent := frmMain;
SetBounds(xy[Image].x, xy[Image].y, wh[Image].x, wh[Image].y);
bmp := frmBitmaps[consts[image]];
OnMouseMove := @MouseMoved;
ONMOUSEDOWN := @OnMouseDown;
OnClick := @OnClickEvents;
isActiveImage[Image] := False;
if (Image = IMG_TAB_NORM_1)then
isLeftTab[Image] := true;
visible := Visibl[Image];
end;
DrawBitmap(bmp, tImages[Image].canvas, 0, 0);
end;
tImages[10].BringToFront;

for i := low(IsActivePanel) to high(IsActivePanel) do
isActivePanel[i] := False;
isActivePanel[IMG_TAB_NORM_1] := True;
senderTab := IMG_TAB_NORM_1;

for i := low(panels) to high(panels) do
begin
panels[i] := TPanel.Create(frmMain);
panels[i].parent := frmMain;
panels[i].SetBounds(tImages[i].left + tImages[i].width,tImages[i].top, 0, tImages[i].height);
end;
panels[IMG_TAB_NORM_1].width := 380;
end;

procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;

procedure ShowFormModal;
begin
frmMain.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;

begin
try
SafeInitForm;
SafeShowFormModal;
finally
time.ENABLED := false;
time.Free;
frmMain.Free;
except
Writeln(ExceptionToString(ExceptionType, ExceptionParam));
end;
end.

EDIT: i find it kind of funny how the form has gotten shorter in lines of code. Not even just from my shortenings of your code, but of my own. More features get added, but the script gets shorter. :p

Coh3n

2010-07-03 20:35:04

Very cool Dan. Does anything flash for you when the panels are sliding from side to side? If not, could just be my WINE again.

Also, I don't like the big grey box where each page is. Just looks ugly in my opinion. You also can't see the location viewer with the grey box there. :p

Dan Cardin

2010-07-03 21:50:20

No flashing for me.

The big grey boxes are panels. The idea is that once everything works, I can just switch out the TPanels for TImages without images loaded into them, so they'll be invisible. But seeing as they'd be invisible, it would make it hard to test it with, so in the mean time, i use TPanels :).

Coh3n

2010-07-03 21:52:11

From: Dan Cardin
No flashing for me.

The big grey boxes are panels. The idea is that once everything works, I can just switch out the TPanels for TImages without images loaded into them, so they'll be invisible. But seeing as they'd be invisible, it would make it hard to test it with, so in the mean time, i use TPanels :).

Ah okay, makes sense. I'm just testing all the changes to the core I made today. So after I commit them, I can properly test the form on Windows and hopefully give some nice feedback. :)

You're doing great, btw.

E: Works 100% better on Windows. I don't get any of the flashing or anything. There was only one thing I noticed. The active panel image stays "indented" only when you hover over the grey panel. I think it should stay indented wherever the mouse is (except when it's on other panels). If not this, then I think there should be a clear distinction between which tab is active and which aren't.

marpis

2010-07-04 10:15:47

From: Dan Cardin
what do you need a google email? [email]candardin@gmail.com[/email]

ok now.

-It was surprisingly simple to get it to always put the tab that you click in the same spot. All it took was a +1. So That's good.
-Made the animation simpler again. I guess it's more efficient since it's not doing unnecessary logic every loop through.
-Got rid of your panel constants because they don't really stand for anything. In this case, an array is better. With that, I'm kind of phasing out isActivePanel, because i don't think its really that needed. You can't have more than one active panel at a time, so i mean…an integer (senderTab) should suffice to say which panel is active at the moment.
-In the midst of getting panels to work. Made it a lot simpler than i was trying for before, and it almost works really well! It seems to do so at first, but then when you start clicking around in the middle ones it screws up. At the moment I don't know why.

program MSIForm;

const


{ PANEL_COUNT = 5;
PANEL_1 = 0;
PANEL_2 = 1;
PANEL_3 = 2;
PANEL_4 = 3;
PANEL_5 = 4; }


IMG_COUNT = 23;
// Used in frmMain
IMG_BGND = 0;
IMG_X_NORM = 1;
IMG_Q_NORM = 2;
IMG_LOAD_TAB_NORM = 3;
IMG_SAVE_TAB_NORM = 4;
IMG_TAB_NORM_1 = 5;
IMG_TAB_NORM_2 = 6;
IMG_TAB_NORM_3 = 7;
IMG_TAB_NORM_4 = 8;

IMG_LOC_ICON_NORM = 9;
IMG_LOC_EXIT_NORM = 10;
IMG_LOC_MAP = 11;
IMG_LOC_NAV = 12;
IMG_LOC_BORD_TOP = 13;
IMG_LOC_BORD_BOTTOM = 14;
IMG_LOC_BORD_LEFT = 15;
IMG_LOC_BORD_RIGHT = 16;
IMG_LOC_BOX_TOP = 17;
IMG_LOC_BOX_LEFT = 18;
IMG_LOC_BOX_RIGHT = 19;
IMG_LOC_BOX_BOTTOM = 20;

// Used in Panel 0 (Is also used for frmMain)
IMG_LOC_LABEL = 21;
IMG_TAB_HINT = 22;

// Used in Panel 1

// Used in Panel 2

// Used in Panel 3

// Used in Panel 4

BITMAP_COUNT = 31;
BGND = 0;
X_NORM = 1;
X_HOVER = 2;
Q_NORM = 3;
Q_HOVER = 4;
LOAD_TAB_NORM = 5;
LOAD_TAB_HOVER = 6;
SAVE_TAB_NORM = 7;
SAVE_TAB_HOVER = 8;
TAB_NORM_1 = 9;
TAB_HOVER_1 = 10;
TAB_NORM_2 = 11;
TAB_HOVER_2 = 12;
TAB_NORM_3 = 13;
TAB_HOVER_3 = 14;
TAB_NORM_4 = 15;
TAB_HOVER_4 = 16;
LOC_ICON_NORM = 17;
LOC_ICON_HOVER = 18;
LOC_EXIT_NORM = 19;
LOC_EXIT_HOVER = 20;
LOC_MAP = 21;
LOC_NAV = 22;
LOC_BORD_TOP = 23;
LOC_BORD_BOTTOM = 24;
LOC_BORD_LEFT = 25;
LOC_BORD_RIGHT = 26;
LOC_BOX_TOP = 27;
LOC_BOX_LEFT = 28;
LOC_LABEL = 29;
TAB_HINT = 30;

var
frmMain: TForm;
time: TTimer;

tImages: Array[0..IMG_COUNT - 1] of TImage;

frmBitmaps: Array [0..BITMAP_COUNT - 1] of Integer;

isActiveImage: Array[0..IMG_COUNT - 1] of Boolean;
isLeftTab: Array[IMG_TAB_NORM_1..IMG_TAB_NORM_4] of Boolean;
isActivePanel: Array[IMG_TAB_NORM_1..IMG_TAB_NORM_4] of Boolean;

MapDragStartX, MapDragStartY: Integer;


panels: array [IMG_TAB_NORM_1..IMG_TAB_NORM_4] of TPanel;


procedure OutsideBox(l,t,r,b, obj: integer);
begin
if tImages[obj].Left > l then
tImages[obj].Left := l;
if tImages[obj].Top > t then
tImages[obj].Top := t;
if tImages[obj].Left < r then
tImages[obj].Left := r;
if tImages[obj].Top < b then
tImages[obj].Top := b;
end;

procedure OnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
BoundL, BoundT: Extended;
begin
case sender of
tImages[IMG_LOC_MAP]:
begin
MapDragStartX := x;
MapDragStartY := y;
end;
tImages[IMG_LOC_NAV]:
begin
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x + (x - left), {T} y + (y - top), {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

OutsideBox(0,0,-345, -354, IMG_LOC_MAP);
end;
end;
end;

var
accel, move, senderTab, pan: integer;
cons: array [IMG_TAB_NORM_1..IMG_TAB_NORM_4] of integer;
procedure TimerTabClick(Sender: TObject);
var
i, e, d, top, bottom: Integer;
truth: boolean;
am: TIntegerArray;
begin
truth := isLeftTab[senderTab];
d := integer(truth)* 2 - 1;
if truth then
begin
top := IMG_TAB_NORM_4
bottom := senderTab + 1;
end else
begin
top := senderTab;
bottom := IMG_TAB_NORM_1
end;

if move = 0 then
for e := bottom to top do
cons[e] := tImages[e].Left;
accel := accel + 2;
move := move + accel;
for i := bottom to top do
if isLeftTab[i] = truth then
tImages[i].Left := tImages[i].Left + accel * d;
if move >= 380 then
begin
for e := bottom to top do
if isLeftTab[e] = truth then
begin
tImages[e].Left := cons[e] + 380 * d;
isLeftTab[e] := not truth;
end;
move := 0;
time.ENABLED := false;
end;

if pan < senderTab then
panels[pan].width := panels[pan].width + accel * d;
if pan > senderTab then
begin
panels[pan].left := panels[pan].left + accel * d;
panels[pan].width := panels[pan].width - accel * d;
end;

if pan > senderTab then
panels[senderTab].width := panels[senderTab].width + accel * d;
if pan < senderTab then
begin
panels[senderTab].left := panels[senderTab].left + accel * d;
panels[senderTab].width := panels[senderTab].width - accel * d;
end;

am := [IMG_LOC_ICON_NORM,IMG_LOC_LABEL,IMG_TAB_HINT];
for i := 0 to high(am) do
tImages[am[i]].Visible := isActivePanel[IMG_TAB_NORM_1];
end;

procedure TabClick(Sender: TObject);
var i: integer;
begin
if not time.ENABLED then
begin
accel := 0;
time.enabled := not time.enabled;
pan := senderTab;
isActivePanel[pan] := false;
for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_4 do
if (Sender = tImages[i]) then
senderTab := i;
isActivePanel[senderTab] := true;
end;
end;

procedure LocViewer(Sender: TObject);
var i: Integer;
am: TintegerArray;
tru: boolean;
begin
am := [IMG_LOC_ICON_NORM, IMG_TAB_HINT, IMG_LOC_LABEL];
case Sender of
tImages[IMG_LOC_ICON_NORM]: tru := true;
tImages[IMG_LOC_EXIT_NORM]: tru := false;
end;

for i := IMG_LOC_EXIT_NORM to IMG_LOC_BOX_BOTTOM do
tImages[i].Visible := Tru;

for i := 0 to high(am) do
tImages[am[i]].Visible := not tru;
end;

procedure Clicked(Sender: TObject);
var
i: Integer;
begin
for i := 0 to BITMAP_COUNT - 1 do
FreeBitmap(frmBitmaps[i]);
frmMain.ModalResult := mrOk;
end;

procedure MouseMoved(Sender: TObject; Shift: TShiftState; x, y: Integer);
var
hi, i, bmp, xdif, ydif, h: Integer;
BoundL, BoundT: Extended;
imgSwap, bmpArr, imgArr: Array of Integer;
begin
bmpArr := [ X_NORM, Q_NORM, LOAD_TAB_NORM,
SAVE_TAB_NORM, TAB_NORM_1, TAB_NORM_2,
TAB_NORM_3, TAB_NORM_4, LOC_ICON_NORM, LOC_EXIT_NORM ]

imgArr := [ IMG_X_NORM, IMG_Q_NORM, IMG_LOAD_TAB_NORM,
IMG_SAVE_TAB_NORM, IMG_TAB_NORM_1, IMG_TAB_NORM_2,
IMG_TAB_NORM_3, IMG_TAB_NORM_4, IMG_LOC_ICON_NORM, IMG_LOC_EXIT_NORM ]
hi := High(bmpArr);
case Sender of
tImages[IMG_BGND], tImages[IMG_LOC_MAP]:
begin
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;

bmp := frmBitmaps[bmpArr[i]];
DrawBitmap(bmp,tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;
end;
for h := 0 to hi do
case Sender of
tImages[imgArr[h]]:
begin
imgSwap := [imgArr[h], frmBitmaps[bmpArr[h] + 1]];
if not (isActiveImage[imgSwap[0]]) then
begin
DrawBitmap(imgSwap[1],tImages[imgSwap[0]].Canvas,0,0);
isActiveImage[imgSwap[0]] := True;
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;
if (i = imgSwap[0] - 1) then
Continue;
if imgSwap[0] = IMG_LOC_EXIT_NORM then
if (i = imgSwap[0] - 2) then
Continue;
if imgSwap[0] = IMG_LOC_ICON_NORM then
if (i = imgSwap[0] - 12) then
Continue;
bmp := frmBitmaps[bmpArr[i]];
DrawBitmap(bmp, tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;
end;
end;
case sender of
tImages[IMG_LOC_MAP]:
begin
if not IsMouseButtonDown(1) then exit;
xdif := x - MapDragStartX;
ydif := y - MapDragStartY;
tImages[IMG_LOC_MAP].Left := tImages[IMG_LOC_MAP].Left + xdif;
tImages[IMG_LOC_MAP].Top := tImages[IMG_LOC_MAP].Top + ydif;

OutsideBox(0,0,-854, -765, IMG_LOC_MAP);

BoundL := -tImages[IMG_LOC_MAP].Left / 7.234 + 376;
BoundT := -tImages[IMG_LOC_MAP].Top / 7.234 + 216;


with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} Round(BoundL), {T} Round(BoundT), {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);
end;
tImages[IMG_LOC_NAV]:
begin
if not IsMouseButtonDown(1) then exit;
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x - 55 - 100, {T} y - 40 - 100, {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

OutsideBox(0, 0, -854, -765, IMG_LOC_MAP);
end;
end;
end;

procedure OnClickEvents(Sender: TObject);
begin
case Sender of
tImages[IMG_X_NORM]: Clicked(Sender);
tImages[IMG_TAB_NORM_1], tImages[IMG_TAB_NORM_2],tImages[IMG_TAB_NORM_3], tImages[IMG_TAB_NORM_4]: TabClick(Sender);
tImages[IMG_LOC_ICON_NORM], tImages[IMG_LOC_EXIT_NORM]: LocViewer(Sender);
end;
end;

procedure InitForm;
var
Image, bmp, hi, i: Integer;
consts: TintegerArray;
bmpArr: TStringArray;
xy, wh: TPointArray;
visibl: TBoolArray;
begin
bmpArr := ['BGND','X_NORM','X_HOVER','Q_NORM','Q_HOVER','LOAD_TAB_NORM','LOAD_TAB_HOVER','SAVE_TAB_NORM','SAVE_TAB_HOVER','TAB_NORM_1','TAB_HOVER_1','TAB_NORM_2','TAB_HOVER_2','TAB_NORM_3','TAB_HOVER_3','TAB_NORM_4','TAB_HOVER_4','LOC_ICON_NORM','LOC_ICON_HOVER','LOC_EXIT_NORM','LOC_EXIT_HOVER','LOC_MAP','LOC_NAV','LOC_BORD_TOP','LOC_BORD_BOTTOM','LOC_BORD_LEFT','LOC_BORD_RIGHT','LOC_BOX_TOP','LOC_BOX_LEFT','LOC_LABEL','TAB_HINT'];
hi := High(frmBitmaps);
for i := 0 to hi do
frmBitmaps[i] := LoadBitmap(ScriptPath + 'Bitmaps\' + bmpArr[i] + '.png');

frmMain := TForm.Create(nil);
with frmMain do
begin
SetBounds({L} 100, {T} 100, {W} 600, {H} 400);
//Position := poScreenCenter;
BorderStyle := bsNone;
end;

time := TTimer.Create(frmMain);
time.ONTIMER := @TimerTabClick;
time.INTERVAL := 10;
time.ENABLED := false;

xy := [Point(0,0), Point(575,7), Point(557,7), Point(7,69), Point(81,69), Point(10{390},100), Point(440,100), Point(490,100), Point(540,100), Point(179,204), Point(475,7), Point(-300,0), Point(369,209), Point(0,0), Point(0,393), Point(0,7), Point(593,7), Point(Round( 300 / 7.234 + 376), 216), Point(Round( 300 / 7.234 + 376), 216 + 1), Point(Round( 300 / 7.234 + 376) + 83, 216 + 1), Point(Round( 300 / 7.234 + 376), 216 + 1 + 54), Point(156,250), Point(208,379)];
wh := [Point(600,400), Point(18,18), Point(18,18), Point(74,22), Point(74,22), Point(50,290), Point(50,290), Point(50,290), Point(50,290), Point(40,41), Point(119,22), Point(1454,1165), Point(215,175), Point(600,7), Point(600,7), Point(7,386), Point(7,386), Point(83, 1), Point(1,55), Point(1,55), Point(83,1), Point(87,11), Point(174,10)];
visibl := [true, true, true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, true, true];
consts := [BGND, X_NORM, Q_NORM, LOAD_TAB_NORM,SAVE_TAB_NORM,TAB_NORM_1, TAB_NORM_2, TAB_NORM_3, TAB_NORM_4, LOC_ICON_NORM, LOC_EXIT_NORM, LOC_MAP, LOC_NAV, LOC_BORD_TOP, LOC_BORD_BOTTOM, LOC_BORD_LEFT, LOC_BORD_RIGHT, LOC_BOX_TOP, LOC_BOX_LEFT, LOC_BOX_LEFT, LOC_BOX_TOP, LOC_LABEL, TAB_HINT];
for Image := 0 to IMG_COUNT - 1 do
begin
tImages[Image] := TImage.Create(frmMain);
with tImages[Image] do
begin
Parent := frmMain;
SetBounds(xy[Image].x, xy[Image].y, wh[Image].x, wh[Image].y);
bmp := frmBitmaps[consts[image]];
OnMouseMove := @MouseMoved;
ONMOUSEDOWN := @OnMouseDown;
OnClick := @OnClickEvents;
isActiveImage[Image] := False;
if (Image = IMG_TAB_NORM_1)then
isLeftTab[Image] := true;
visible := Visibl[Image];
end;
DrawBitmap(bmp, tImages[Image].canvas, 0, 0);
end;
tImages[10].BringToFront;

for i := low(IsActivePanel) to high(IsActivePanel) do
isActivePanel[i] := False;
isActivePanel[IMG_TAB_NORM_1] := True;
senderTab := IMG_TAB_NORM_1;

for i := low(panels) to high(panels) do
begin
panels[i] := TPanel.Create(frmMain);
panels[i].parent := frmMain;
panels[i].SetBounds(tImages[i].left + tImages[i].width,tImages[i].top, 0, tImages[i].height);
end;
panels[IMG_TAB_NORM_1].width := 380;
end;

procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;

procedure ShowFormModal;
begin
frmMain.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;

begin
try
SafeInitForm;
SafeShowFormModal;
finally
time.ENABLED := false;
time.Free;
frmMain.Free;
except
Writeln(ExceptionToString(ExceptionType, ExceptionParam));
end;
end.

EDIT: i find it kind of funny how the form has gotten shorter in lines of code. Not even just from my shortenings of your code, but of my own. More features get added, but the script gets shorter. :p


This tries to open the form, but only shows a couple of black/grey boxes and crashes simba.. :(

Sabzi

2010-07-04 10:56:10

From: marpis
This tries to open the form, but only shows a couple of black/grey boxes and crashes simba.. :(


Because you should use this instead of the script already in the repository.
There are the images.
https://msiform.googlecode.com/svn/trunk/

Dan Cardin

2010-07-11 21:01:42

That's why I dislike images. It would be nice to get one image to get all the images off of, but it would be more work than it was worth because they're all different sizes. It would also be nice to have it use panels or whatever so that it's at least usable without the images, if not pretty. But even that would require doing checking to see if the images are there and be a hassle. And it wouldn't even work fully because you'll need the map eventually. And now that I've made this version so great, you can't go and switch the style now! :p.

EDIT: I only changed a few lines, but now the widths/heights don't need to be updated when/if the images change. Don't know why i didn't think of that earlier.
program MSIForm;

const
IMG_COUNT = 23;
// Used in frmMain
IMG_BGND = 0;
IMG_X_NORM = 1;
IMG_Q_NORM = 2;
IMG_LOAD_TAB_NORM = 3;
IMG_SAVE_TAB_NORM = 4;
IMG_TAB_NORM_1 = 5;
IMG_TAB_NORM_2 = 6;
IMG_TAB_NORM_3 = 7;
IMG_TAB_NORM_4 = 8;

// Used in Panel 0 (Is also used for frmMain)
IMG_LOC_ICON_NORM = 9;
IMG_LOC_EXIT_NORM = 10;
IMG_LOC_MAP = 11;
IMG_LOC_NAV = 12;
IMG_LOC_BORD_TOP = 13;
IMG_LOC_BORD_BOTTOM = 14;
IMG_LOC_BORD_LEFT = 15;
IMG_LOC_BORD_RIGHT = 16;
IMG_LOC_BOX_TOP = 17;
IMG_LOC_BOX_LEFT = 18;
IMG_LOC_BOX_RIGHT = 19;
IMG_LOC_BOX_BOTTOM = 20;

IMG_LOC_LABEL = 21;
IMG_TAB_HINT = 22;

// Used in Panel 1

// Used in Panel 2

// Used in Panel 3

// Used in Panel 4

BITMAP_COUNT = 31;
BGND = 0;
X_NORM = 1;
X_HOVER = 2;
Q_NORM = 3;
Q_HOVER = 4;
LOAD_TAB_NORM = 5;
LOAD_TAB_HOVER = 6;
SAVE_TAB_NORM = 7;
SAVE_TAB_HOVER = 8;
TAB_NORM_1 = 9;
TAB_HOVER_1 = 10;
TAB_NORM_2 = 11;
TAB_HOVER_2 = 12;
TAB_NORM_3 = 13;
TAB_HOVER_3 = 14;
TAB_NORM_4 = 15;
TAB_HOVER_4 = 16;
LOC_ICON_NORM = 17;
LOC_ICON_HOVER = 18;
LOC_EXIT_NORM = 19;
LOC_EXIT_HOVER = 20;
LOC_MAP = 21;
LOC_NAV = 22;
LOC_BORD_TOP = 23;
LOC_BORD_BOTTOM = 24;
LOC_BORD_LEFT = 25;
LOC_BORD_RIGHT = 26;
LOC_BOX_TOP = 27;
LOC_BOX_LEFT = 28;
LOC_LABEL = 29;
TAB_HINT = 30;

var
frmMain: TForm;
time: TTimer;

tImages: Array[0..IMG_COUNT - 1] of TImage;

frmBitmaps: Array [0..BITMAP_COUNT - 1] of Integer;

isActiveImage: Array[0..IMG_COUNT - 1] of Boolean;
isLeftTab: Array[IMG_TAB_NORM_1..IMG_TAB_NORM_4] of Boolean;

MapDragStartX, MapDragStartY: Integer;

panels: array [IMG_TAB_NORM_1..IMG_TAB_NORM_4] of TPanel;


procedure OutsideBox(l,t,r,b, obj: integer);
begin
if tImages[obj].Left > l then
tImages[obj].Left := l;
if tImages[obj].Top > t then
tImages[obj].Top := t;
if tImages[obj].Left < r then
tImages[obj].Left := r;
if tImages[obj].Top < b then
tImages[obj].Top := b;
end;

procedure OnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
BoundL, BoundT: Extended;
begin
case sender of
tImages[IMG_LOC_MAP]:
begin
MapDragStartX := x;
MapDragStartY := y;
end;
tImages[IMG_LOC_NAV]:
begin
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x + (x - left), {T} y + (y - top), {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

OutsideBox(0,0,-345, -354, IMG_LOC_MAP);
end;
end;
end;

var
accel, move, senderTab, pan: integer;
cons: array [IMG_TAB_NORM_1..IMG_TAB_NORM_4] of integer;
procedure TimerTabClick(Sender: TObject);
var
i, e, d, top, bottom: Integer;
truth: boolean;
begin
truth := isLeftTab[senderTab];
d := integer(truth)* 2 - 1;
if truth then
begin
top := IMG_TAB_NORM_4
bottom := senderTab + 1;
end else
begin
top := senderTab;
bottom := IMG_TAB_NORM_1
end;

if move = 0 then
for e := bottom to top do
cons[e] := tImages[e].Left;
accel := accel + 2;
move := move + accel;
for i := bottom to top do
if isLeftTab[i] = truth then
tImages[i].Left := tImages[i].Left + accel * d;
if move >= 380 then
begin
for e := bottom to top do
if isLeftTab[e] = truth then
begin
tImages[e].Left := cons[e] + 380 * d;
isLeftTab[e] := not truth;
end;
move := 0;
time.ENABLED := false;
end;

if pan < senderTab then
begin
panels[pan].width := panels[pan].width + accel * d;
panels[senderTab].left := panels[senderTab].left + accel * d;
panels[senderTab].width := panels[senderTab].width - accel * d;
end;
if pan > senderTab then
begin
panels[pan].left := panels[pan].left + accel * d;
panels[pan].width := panels[pan].width - accel * d;
panels[senderTab].width := panels[senderTab].width + accel * d;
end;
end;

procedure TabClick(Sender: TObject);
var
i: integer;
begin
if not time.ENABLED then
begin
accel := 0;
time.enabled := not time.enabled;
pan := senderTab;
for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_4 do
if (Sender = tImages[i]) then
senderTab := i;
end;
end;

procedure LocViewer(Sender: TObject);
var
i: Integer;
am: TintegerArray;
tru: boolean;
begin
am := [IMG_LOC_ICON_NORM, IMG_TAB_HINT, IMG_LOC_LABEL];
case Sender of
tImages[IMG_LOC_ICON_NORM]: tru := true;
tImages[IMG_LOC_EXIT_NORM]: tru := false;
end;

for i := IMG_LOC_EXIT_NORM to IMG_LOC_BOX_BOTTOM do
tImages[i].Visible := tru;

for i := 0 to high(am) do
tImages[am[i]].Visible := not tru;
end;

procedure Clicked(Sender: TObject);
var
i: Integer;
begin
for i := 0 to BITMAP_COUNT - 1 do
FreeBitmap(frmBitmaps[i]);
frmMain.ModalResult := mrOk;
end;

procedure MouseMoved(Sender: TObject; Shift: TShiftState; x, y: Integer);
var
hi, i, bmp, xdif, ydif, h: Integer;
BoundL, BoundT: Extended;
imgSwap, bmpArr, imgArr: Array of Integer;
begin
bmpArr := [ X_NORM, Q_NORM, LOAD_TAB_NORM,
SAVE_TAB_NORM, TAB_NORM_1, TAB_NORM_2,
TAB_NORM_3, TAB_NORM_4, LOC_ICON_NORM, LOC_EXIT_NORM ]

imgArr := [ IMG_X_NORM, IMG_Q_NORM, IMG_LOAD_TAB_NORM,
IMG_SAVE_TAB_NORM, IMG_TAB_NORM_1, IMG_TAB_NORM_2,
IMG_TAB_NORM_3, IMG_TAB_NORM_4, IMG_LOC_ICON_NORM, IMG_LOC_EXIT_NORM ]
hi := High(bmpArr);
case Sender of
tImages[IMG_BGND], tImages[IMG_LOC_MAP]:
begin
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;

bmp := frmBitmaps[bmpArr[i]];
DrawBitmap(bmp,tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;
end;
for h := 0 to hi do
case Sender of
tImages[imgArr[h]]:
begin
imgSwap := [imgArr[h], frmBitmaps[bmpArr[h] + 1]];
if not (isActiveImage[imgSwap[0]]) then
begin
DrawBitmap(imgSwap[1],tImages[imgSwap[0]].Canvas,0,0);
isActiveImage[imgSwap[0]] := True;
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;
if (i = imgSwap[0] - 1) then
Continue;
if imgSwap[0] = IMG_LOC_EXIT_NORM then
if (i = imgSwap[0] - 2) then
Continue;
if imgSwap[0] = IMG_LOC_ICON_NORM then
if (i = imgSwap[0] - 12) then
Continue;
bmp := frmBitmaps[bmpArr[i]];
DrawBitmap(bmp, tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;
end;
end;
case sender of
tImages[IMG_LOC_MAP]:
begin
if not IsMouseButtonDown(1) then exit;
xdif := x - MapDragStartX;
ydif := y - MapDragStartY;
tImages[IMG_LOC_MAP].Left := tImages[IMG_LOC_MAP].Left + xdif;
tImages[IMG_LOC_MAP].Top := tImages[IMG_LOC_MAP].Top + ydif;

OutsideBox(0,0,-854, -765, IMG_LOC_MAP);

BoundL := -tImages[IMG_LOC_MAP].Left / 7.234 + 376;
BoundT := -tImages[IMG_LOC_MAP].Top / 7.234 + 216;


with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} Round(BoundL), {T} Round(BoundT), {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);
end;
tImages[IMG_LOC_NAV]:
begin
if not IsMouseButtonDown(1) then exit;
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x - 55 - 100, {T} y - 40 - 100, {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

OutsideBox(0, 0, -854, -765, IMG_LOC_MAP);
end;
end;
end;

procedure OnClickEvents(Sender: TObject);
begin
case Sender of
tImages[IMG_X_NORM]: Clicked(Sender);
tImages[IMG_TAB_NORM_1], tImages[IMG_TAB_NORM_2],tImages[IMG_TAB_NORM_3], tImages[IMG_TAB_NORM_4]: TabClick(Sender);
tImages[IMG_LOC_ICON_NORM], tImages[IMG_LOC_EXIT_NORM]: LocViewer(Sender);
end;
end;

procedure InitForm;
var
i: Integer;
consts: TintegerArray;
bmpArr: TStringArray;
xy: TPointArray;
visibl: TBoolArray;
wh: TPoint;
begin
bmpArr := ['BGND','X_NORM','X_HOVER','Q_NORM','Q_HOVER','LOAD_TAB_NORM','LOAD_TAB_HOVER','SAVE_TAB_NORM','SAVE_TAB_HOVER','TAB_NORM_1','TAB_HOVER_1','TAB_NORM_2','TAB_HOVER_2','TAB_NORM_3','TAB_HOVER_3','TAB_NORM_4','TAB_HOVER_4','LOC_ICON_NORM','LOC_ICON_HOVER','LOC_EXIT_NORM','LOC_EXIT_HOVER','LOC_MAP','LOC_NAV','LOC_BORD_TOP','LOC_BORD_BOTTOM','LOC_BORD_LEFT','LOC_BORD_RIGHT','LOC_BOX_TOP','LOC_BOX_LEFT','LOC_LABEL','TAB_HINT'];
for i := 0 to High(frmBitmaps) do
frmBitmaps[i] := LoadBitmap(ScriptPath + 'Bitmaps\' + bmpArr[i] + '.png');

frmMain := TForm.Create(nil);
frmMain.SetBounds({L} 100, {T} 100, {W} 600, {H} 400);
//frmMain.Position := poScreenCenter;
frmMain.BorderStyle := bsNone;

time := TTimer.Create(frmMain);
time.ONTIMER := @TimerTabClick;
time.INTERVAL := 10;
time.ENABLED := false;

xy := [Point(0,0), Point(575,7), Point(557,7), Point(7,69), Point(81,69), Point(10, 100), Point(440,100), Point(490,100), Point(540,100), Point(179,204), Point(475,7), Point(-300,0), Point(369,209), Point(0,0), Point(0,393), Point(0,7), Point(593,7), Point(Round( 300 / 7.234 + 376), 216), Point(Round( 300 / 7.234 + 376), 216 + 1), Point(Round( 300 / 7.234 + 376) + 83, 216 + 1), Point(Round( 300 / 7.234 + 376), 216 + 1 + 54), Point(156,250), Point(208,379)];
visibl := [true, true, true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, true, true];
consts := [BGND, X_NORM, Q_NORM, LOAD_TAB_NORM,SAVE_TAB_NORM,TAB_NORM_1, TAB_NORM_2, TAB_NORM_3, TAB_NORM_4, LOC_ICON_NORM, LOC_EXIT_NORM, LOC_MAP, LOC_NAV, LOC_BORD_TOP, LOC_BORD_BOTTOM, LOC_BORD_LEFT, LOC_BORD_RIGHT, LOC_BOX_TOP, LOC_BOX_LEFT, LOC_BOX_LEFT, LOC_BOX_TOP, LOC_LABEL, TAB_HINT];

for i := low(panels) to high(panels) do
begin
panels[i] := TPanel.Create(frmMain);
panels[i].parent := frmMain;
GetBitmapSize(frmBitmaps[consts[i]], wh.x, wh.y);
panels[i].SetBounds(xy[i].x + wh.x, xy[i].y, 0, wh.y);
end;

for i := 0 to IMG_COUNT - 1 do
begin
if i < 9 then
tImages[i] := TImage.Create(frmMain)
else
tImages[i] := TImage.Create(panels[low(panels)]);
with tImages[i] do
begin
if i < 9 then
Parent := frmMain
else
Parent := panels[low(panels)];
GetBitmapSize(frmBitmaps[consts[i]], wh.x, wh.y);
SetBounds(xy[i].x, xy[i].y, wh.x, wh.y);
OnMouseMove := @MouseMoved;
ONMOUSEDOWN := @OnMouseDown;
OnClick := @OnClickEvents;
isActiveImage[i] := False;
if (i = IMG_TAB_NORM_1)then
isLeftTab[i] := true;
visible := Visibl[i];
end;
DrawBitmap(frmBitmaps[consts[i]], tImages[i].canvas, 0, 0);
end;

panels[IMG_TAB_NORM_1].width := 380;
tImages[10].BringToFront;
senderTab := IMG_TAB_NORM_1;
end;

procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;

procedure ShowFormModal;
begin
frmMain.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;

begin
try
SafeInitForm;
SafeShowFormModal;
finally
time.ENABLED := false;
time.Free;
frmMain.Free;
except
Writeln(ExceptionToString(ExceptionType, ExceptionParam));
end;
end.
Still has the problem because i haven't had much time to work on it. I also don't know if we want me to undo what I've done to the map (it wouldn't really be undoing…more just making the map look like it did before by moving and resizing the panel) or should we adapt the map to fit the tab or should we make the whole form bigger to accommodate for the map a bit. I like the map being in tab, but very probably the form would need to be enlarged.

Sir R. M8gic1an

2010-07-16 10:27:29

I like the map in the tab too.

Btw, did this just sort of die?

~RM

Dan Cardin

2010-07-16 12:54:58

A little bit. I may be the only person that understand the form code well enough to do a lot. Though it may just be that no one else is interested in trying to do things. I don't really have all that much to do until i can figure out that bug with the tab switching that happens in certain cases or until someone makes new images for further tabs. or finds a bug or gives me critiques.

Sir R. M8gic1an

2010-07-16 13:09:21

From: Dan Cardin
A little bit. I may be the only person that understand the form code well enough to do a lot. Though it may just be that no one else is interested in trying to do things. I don't really have all that much to do until i can figure out that bug with the tab switching that happens in certain cases or until someone makes new images for further tabs. or finds a bug or gives me critiques.


I can easily give you a list of what I would like to see and where ;)

Helpful? :p

~RM

Dan Cardin

2010-07-16 13:32:12

possibly indeedy, but for the look we seem to be going in, you'll want all the things you're going to say as images. I could put in filler things, but that will really only give you the correct placement and size, not the functionality (well you'll have functionality, but not the same that will be there when its actually made with images)

ReadySteadyGo

2010-07-16 13:39:58

From: Dan Cardin
I may be the only person that understand the form code well enough to do a lot.


Exactly my previous point with you doing unnecessary code shortening. I will rewrite the extras that you have done in what I think is a cleaner way of doing it.

edit: Really nice stuff dan. Very nice with the acceleration :)

edit: I take back what I said. I like the shortening :P I'm making new images for the panels and will try to iron out some of the bugs. With the Panels: as you can only have the grey bg. How about using an array named with numbered constants of images?

edit: Dan I have committed your version along with:
  • New slimmer tab images
  • Tab images installed into script
  • Hover overs done
  • The original logo with proper blending
However I can't get the 5th tab to slide. See if you can fix it please. I'm off out.

SVN repo: https://msiform.googlecode.com/svn/trunk/

Dan Cardin

2010-07-16 21:15:31

your version gave me errors, which i now just found out was because cons was reliant only went to IMG_4. It doesn't slide because you didn't add it to OnClickEvents. You missing those two things prompted me to add a PANEL_NUM const, so now, you should be able to just add that, and the actual consts for the new panel, should you need to change the number again, and it everything should be good (well, except you'll need to update the number 10 in the form init part…and update the arrays in MouseMoved…but those can't really be helped without making things complicated.) :)

program MSIForm;

const
IMG_COUNT = 24;
// Used in frmMain
IMG_BGND = 0;
IMG_X_NORM = 1;
IMG_Q_NORM = 2;
IMG_LOAD_TAB_NORM = 3;
IMG_SAVE_TAB_NORM = 4;
IMG_TAB_NORM_1 = 5;
IMG_TAB_NORM_2 = 6;
IMG_TAB_NORM_3 = 7;
IMG_TAB_NORM_4 = 8;
IMG_TAB_NORM_5 = 9;

// Used in Panel 0 (Is also used for frmMain)
IMG_LOC_ICON_NORM = 10;
IMG_LOC_EXIT_NORM = 11;
IMG_LOC_MAP = 12;
IMG_LOC_NAV = 13;
IMG_LOC_BORD_TOP = 14;
IMG_LOC_BORD_BOTTOM = 15;
IMG_LOC_BORD_LEFT = 16;
IMG_LOC_BORD_RIGHT = 17;
IMG_LOC_BOX_TOP = 18;
IMG_LOC_BOX_LEFT = 19;
IMG_LOC_BOX_RIGHT = 20;
IMG_LOC_BOX_BOTTOM = 21;

IMG_LOC_LABEL = 22;
IMG_TAB_HINT = 23;

PANEL_NUM = 5;
// Used in Panel 1

// Used in Panel 2

// Used in Panel 3

// Used in Panel 4

BITMAP_COUNT = 33;
BGND = 0;
X_NORM = 1;
X_HOVER = 2;
Q_NORM = 3;
Q_HOVER = 4;
LOAD_TAB_NORM = 5;
LOAD_TAB_HOVER = 6;
SAVE_TAB_NORM = 7;
SAVE_TAB_HOVER = 8;
TAB_NORM_1 = 9;
TAB_HOVER_1 = 10;
TAB_NORM_2 = 11;
TAB_HOVER_2 = 12;
TAB_NORM_3 = 13;
TAB_HOVER_3 = 14;
TAB_NORM_4 = 15;
TAB_HOVER_4 = 16;
TAB_NORM_5 = 17;
TAB_HOVER_5 = 18;
LOC_ICON_NORM = 19;
LOC_ICON_HOVER = 20;
LOC_EXIT_NORM = 21;
LOC_EXIT_HOVER = 22;
LOC_MAP = 23;
LOC_NAV = 24;
LOC_BORD_TOP = 25;
LOC_BORD_BOTTOM = 26;
LOC_BORD_LEFT = 27;
LOC_BORD_RIGHT = 28;
LOC_BOX_TOP = 29;
LOC_BOX_LEFT = 30;
LOC_LABEL = 31;
TAB_HINT = 32;

var
frmMain: TForm;
time: TTimer;

tImages: Array[0..IMG_COUNT - 1] of TImage;

frmBitmaps: Array [0..BITMAP_COUNT - 1] of Integer;

isActiveImage: Array[0..IMG_COUNT - 1] of Boolean;
isLeftTab: Array[IMG_TAB_NORM_1..IMG_TAB_NORM_1 + PANEL_NUM - 1] of Boolean;

MapDragStartX, MapDragStartY: Integer;

panels: array [IMG_TAB_NORM_1..IMG_TAB_NORM_1 + PANEL_NUM - 1] of TPanel;


procedure OutsideBox(l,t,r,b, obj: integer);
begin
if tImages[obj].Left > l then
tImages[obj].Left := l;
if tImages[obj].Top > t then
tImages[obj].Top := t;
if tImages[obj].Left < r then
tImages[obj].Left := r;
if tImages[obj].Top < b then
tImages[obj].Top := b;
end;

procedure OnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
BoundL, BoundT: Extended;
begin
case sender of
tImages[IMG_LOC_MAP]:
begin
MapDragStartX := x;
MapDragStartY := y;
end;
tImages[IMG_LOC_NAV]:
begin
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x + (x - left), {T} y + (y - top), {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

OutsideBox(0,0,-345, -354, IMG_LOC_MAP);
end;
end;
end;

var
accel, move, senderTab, pan: integer;
cons: array [IMG_TAB_NORM_1..IMG_TAB_NORM_1 + PANEL_NUM - 1] of integer;

procedure TimerTabClick(Sender: TObject);
var
i, e, d, top, bottom: Integer;
begin
d := integer(isLeftTab[senderTab])* 2 - 1;
if isLeftTab[senderTab] then
begin
top := IMG_TAB_NORM_1 + PANEL_NUM - 1
bottom := senderTab + 1;
end else
begin
top := senderTab;
bottom := IMG_TAB_NORM_1
end;

if move = 0 then
for e := bottom to top do
cons[e] := tImages[e].Left;
accel := accel + 2;
move := move + accel;
for i := bottom to top do
if isLeftTab[i] = isLeftTab[senderTab] then
tImages[i].Left := tImages[i].Left + accel * d;
if move >= 377 then
begin
for e := bottom to top do
if isLeftTab[e] = isLeftTab[senderTab] then
begin
tImages[e].Left := cons[e] + 377 * d;
isLeftTab[e] := not isLeftTab[senderTab];
end;
move := 0;
time.ENABLED := false;
end;

if pan < senderTab then
begin
panels[pan].width := panels[pan].width + accel * d;
panels[senderTab].left := panels[senderTab].left + accel * d;
panels[senderTab].width := panels[senderTab].width - accel * d;
end;
if pan > senderTab then
begin
panels[pan].left := panels[pan].left + accel * d;
panels[pan].width := panels[pan].width - accel * d;
panels[senderTab].width := panels[senderTab].width + accel * d;
end;
end;

procedure TabClick(Sender: TObject);
var
i: integer;
begin
if not time.ENABLED then
begin
accel := 0;
time.enabled := not time.enabled;
pan := senderTab;
for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_1 + PANEL_NUM - 1 do
if (Sender = tImages[i]) then
senderTab := i;
end;
end;

procedure LocViewer(Sender: TObject);
var
i: Integer;
am: TintegerArray;
tru: boolean;
begin
am := [IMG_LOC_ICON_NORM, IMG_TAB_HINT, IMG_LOC_LABEL];
case Sender of
tImages[IMG_LOC_ICON_NORM]: tru := true;
tImages[IMG_LOC_EXIT_NORM]: tru := false;
end;

for i := IMG_LOC_EXIT_NORM to IMG_LOC_BOX_BOTTOM do
tImages[i].Visible := tru;

for i := 0 to high(am) do
tImages[am[i]].Visible := not tru;
end;

procedure Clicked(Sender: TObject);
var
i: Integer;
begin
for i := 0 to BITMAP_COUNT - 1 do
FreeBitmap(frmBitmaps[i]);
frmMain.ModalResult := mrOk;
end;

procedure MouseMoved(Sender: TObject; Shift: TShiftState; x, y: Integer);
var
hi, i, bmp, xdif, ydif, h: Integer;
BoundL, BoundT: Extended;
imgSwap, bmpArr, imgArr: Array of Integer;
begin
bmpArr := [ X_NORM, Q_NORM, LOAD_TAB_NORM,
SAVE_TAB_NORM, TAB_NORM_1, TAB_NORM_2,
TAB_NORM_3, TAB_NORM_4, TAB_NORM_5, LOC_ICON_NORM, LOC_EXIT_NORM ]

imgArr := [ IMG_X_NORM, IMG_Q_NORM, IMG_LOAD_TAB_NORM,
IMG_SAVE_TAB_NORM, IMG_TAB_NORM_1, IMG_TAB_NORM_2,
IMG_TAB_NORM_3, IMG_TAB_NORM_4, IMG_TAB_NORM_5, IMG_LOC_ICON_NORM, IMG_LOC_EXIT_NORM ]
hi := High(bmpArr);
case Sender of
tImages[IMG_BGND], tImages[IMG_LOC_MAP]:
begin
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;

bmp := frmBitmaps[bmpArr[i]];
DrawBitmap(bmp,tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;
end;
for h := 0 to hi do
case Sender of
tImages[imgArr[h]]:
begin
imgSwap := [imgArr[h], frmBitmaps[bmpArr[h] + 1]];
if not (isActiveImage[imgSwap[0]]) then
begin
DrawBitmap(imgSwap[1],tImages[imgSwap[0]].Canvas,0,0);
isActiveImage[imgSwap[0]] := True;
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;
if (i = imgSwap[0] - 1) then
Continue;
if imgSwap[0] = IMG_LOC_EXIT_NORM then
if (i = imgSwap[0]) then
Continue;
if imgSwap[0] = IMG_LOC_ICON_NORM then
if (i = imgSwap[0] - 10) then
Continue;
bmp := frmBitmaps[bmpArr[i]];
DrawBitmap(bmp, tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;
end;
end;
case sender of
tImages[IMG_LOC_MAP]:
begin
if not IsMouseButtonDown(1) then exit;
xdif := x - MapDragStartX;
ydif := y - MapDragStartY;
tImages[IMG_LOC_MAP].Left := tImages[IMG_LOC_MAP].Left + xdif;
tImages[IMG_LOC_MAP].Top := tImages[IMG_LOC_MAP].Top + ydif;

OutsideBox(0,0,-854, -765, IMG_LOC_MAP);

BoundL := -tImages[IMG_LOC_MAP].Left / 7.234 + 376;
BoundT := -tImages[IMG_LOC_MAP].Top / 7.234 + 216;


with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} Round(BoundL), {T} Round(BoundT), {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);
end;
tImages[IMG_LOC_NAV]:
begin
if not IsMouseButtonDown(1) then exit;
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x - 55 - 100, {T} y - 40 - 100, {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

OutsideBox(0, 0, -854, -765, IMG_LOC_MAP);
end;
end;
end;

procedure OnClickEvents(Sender: TObject);
var i: integer;
begin
for i := 0 to PANEL_NUM - 1 do
case sender of
tImages[IMG_TAB_NORM_1 + i]: TabClick(Sender);
end;
case Sender of
tImages[IMG_X_NORM]: Clicked(Sender);
tImages[IMG_LOC_ICON_NORM], tImages[IMG_LOC_EXIT_NORM]: LocViewer(Sender);
end;
end;

procedure InitForm;
var
i: Integer;
consts: TintegerArray;
bmpArr: TStringArray;
xy: TPointArray;
visibl: TBoolArray;
wh: TPoint;
begin
bmpArr := ['BGND','X_NORM','X_HOVER','Q_NORM','Q_HOVER','LOAD_TAB_NORM','LOAD_TAB_HOVER','SAVE_TAB_NORM','SAVE_TAB_HOVER','TAB_NORM_1','TAB_HOVER_1','TAB_NORM_2','TAB_HOVER_2','TAB_NORM_3','TAB_HOVER_3','TAB_NORM_4','TAB_HOVER_4','TAB_NORM_5','TAB_HOVER_5','LOC_ICON_NORM','LOC_ICON_HOVER','LOC_EXIT_NORM','LOC_EXIT_HOVER','LOC_MAP','LOC_NAV','LOC_BORD_TOP','LOC_BORD_BOTTOM','LOC_BORD_LEFT','LOC_BORD_RIGHT','LOC_BOX_TOP','LOC_BOX_LEFT','LOC_LABEL','TAB_HINT'];
for i := 0 to High(frmBitmaps) do
frmBitmaps[i] := LoadBitmap(ScriptPath + 'Bitmaps\' + bmpArr[i] + '.png');

frmMain := TForm.Create(nil);
frmMain.SetBounds({L} 100, {T} 100, {W} 600, {H} 400);
//frmMain.Position := poScreenCenter;
frmMain.BorderStyle := bsNone;

time := TTimer.Create(frmMain);
with time do
begin
ONTIMER := @TimerTabClick;
INTERVAL := 10;
ENABLED := false;
end;

xy := [Point(0,0), Point(575,7), Point(557,7), Point(7,69), Point(81,69), Point(9, 100), Point(427,100), Point(468,100), Point(509,100), Point(550,100), Point(179,204), Point(475,7), Point(-300,0), Point(369,209), Point(0,0), Point(0,393), Point(0,7), Point(593,7), Point(Round( 300 / 7.234 + 376), 216), Point(Round( 300 / 7.234 + 376), 216 + 1), Point(Round( 300 / 7.234 + 376) + 83, 216 + 1), Point(Round( 300 / 7.234 + 376), 216 + 1 + 54), Point(156,250), Point(208,379)];
visibl := [true, true, true, true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, true, true];
consts := [BGND, X_NORM, Q_NORM, LOAD_TAB_NORM,SAVE_TAB_NORM,TAB_NORM_1, TAB_NORM_2, TAB_NORM_3, TAB_NORM_4, TAB_NORM_5, LOC_ICON_NORM, LOC_EXIT_NORM, LOC_MAP, LOC_NAV, LOC_BORD_TOP, LOC_BORD_BOTTOM, LOC_BORD_LEFT, LOC_BORD_RIGHT, LOC_BOX_TOP, LOC_BOX_LEFT, LOC_BOX_LEFT, LOC_BOX_TOP, LOC_LABEL, TAB_HINT];

for i := low(panels) to high(panels) do
begin
panels[i] := TPanel.Create(frmMain);
panels[i].parent := frmMain;
GetBitmapSize(frmBitmaps[consts[i]], wh.x, wh.y);
panels[i].SetBounds(xy[i].x + wh.x, xy[i].y, 0, wh.y);
end;

for i := 0 to IMG_COUNT - 1 do
begin
if i < 10 then
tImages[i] := TImage.Create(frmMain)
else
tImages[i] := TImage.Create(panels[low(panels)]);
with tImages[i] do
begin
if i < 10 then
Parent := frmMain
else
Parent := panels[low(panels)];
GetBitmapSize(frmBitmaps[consts[i]], wh.x, wh.y);
SetBounds(xy[i].x, xy[i].y, wh.x, wh.y);
OnMouseMove := @MouseMoved;
ONMOUSEDOWN := @OnMouseDown;
OnClick := @OnClickEvents;
isActiveImage[i] := False;
visible := Visibl[i];
end;
DrawBitmap(frmBitmaps[consts[i]], tImages[i].canvas, 0, 0);
end;

isLeftTab[IMG_TAB_NORM_1] := true;
panels[IMG_TAB_NORM_1].width := 378;
tImages[10].BringToFront;
senderTab := IMG_TAB_NORM_1;
end;

procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;

procedure ShowFormModal;
begin
frmMain.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;

begin
try
SafeInitForm;
SafeShowFormModal;
finally
time.ENABLED := false;
time.Free;
frmMain.Free;
except
Writeln(ExceptionToString(ExceptionType, ExceptionParam));
end;
end.

as for the panels, again, they're a place holder. You can just change TPanel to TImage in the declaration and the init parts and it will work exactly the same, just without a background. But since they still don't move correctly, it would just make things harder.

EDIT: crap. i don't know why but i thought i had tested this a while ago and it worked…i guess not. Timages can't be parents of things. So the next best thing is to just do add this to the panel creation part.

panels.BEVELWIDTH := 0;
panels.COLOR := 1909544;

also what did you mean by tab images installed into script?

ReadySteadyGo

2010-07-16 21:42:22

From: Dan Cardin
your version gave me errors, which i now just found out was because cons was reliant only went to IMG_4. It doesn't slide because you didn't add it to OnClickEvents. You missing those two things prompted me to add a PANEL_NUM const, so now, you should be able to just add that, and the actual consts for the new panel, should you need to change the number again, and it everything should be good (well, except you'll need to update the number 10 in the form init part…and update the arrays in MouseMoved…but those can't really be helped without making things complicated.) :)

program MSIForm;

const
IMG_COUNT = 24;
// Used in frmMain
IMG_BGND = 0;
IMG_X_NORM = 1;
IMG_Q_NORM = 2;
IMG_LOAD_TAB_NORM = 3;
IMG_SAVE_TAB_NORM = 4;
IMG_TAB_NORM_1 = 5;
IMG_TAB_NORM_2 = 6;
IMG_TAB_NORM_3 = 7;
IMG_TAB_NORM_4 = 8;
IMG_TAB_NORM_5 = 9;

// Used in Panel 0 (Is also used for frmMain)
IMG_LOC_ICON_NORM = 10;
IMG_LOC_EXIT_NORM = 11;
IMG_LOC_MAP = 12;
IMG_LOC_NAV = 13;
IMG_LOC_BORD_TOP = 14;
IMG_LOC_BORD_BOTTOM = 15;
IMG_LOC_BORD_LEFT = 16;
IMG_LOC_BORD_RIGHT = 17;
IMG_LOC_BOX_TOP = 18;
IMG_LOC_BOX_LEFT = 19;
IMG_LOC_BOX_RIGHT = 20;
IMG_LOC_BOX_BOTTOM = 21;

IMG_LOC_LABEL = 22;
IMG_TAB_HINT = 23;

PANEL_NUM = 5;
// Used in Panel 1

// Used in Panel 2

// Used in Panel 3

// Used in Panel 4

BITMAP_COUNT = 33;
BGND = 0;
X_NORM = 1;
X_HOVER = 2;
Q_NORM = 3;
Q_HOVER = 4;
LOAD_TAB_NORM = 5;
LOAD_TAB_HOVER = 6;
SAVE_TAB_NORM = 7;
SAVE_TAB_HOVER = 8;
TAB_NORM_1 = 9;
TAB_HOVER_1 = 10;
TAB_NORM_2 = 11;
TAB_HOVER_2 = 12;
TAB_NORM_3 = 13;
TAB_HOVER_3 = 14;
TAB_NORM_4 = 15;
TAB_HOVER_4 = 16;
TAB_NORM_5 = 17;
TAB_HOVER_5 = 18;
LOC_ICON_NORM = 19;
LOC_ICON_HOVER = 20;
LOC_EXIT_NORM = 21;
LOC_EXIT_HOVER = 22;
LOC_MAP = 23;
LOC_NAV = 24;
LOC_BORD_TOP = 25;
LOC_BORD_BOTTOM = 26;
LOC_BORD_LEFT = 27;
LOC_BORD_RIGHT = 28;
LOC_BOX_TOP = 29;
LOC_BOX_LEFT = 30;
LOC_LABEL = 31;
TAB_HINT = 32;

var
frmMain: TForm;
time: TTimer;

tImages: Array[0..IMG_COUNT - 1] of TImage;

frmBitmaps: Array [0..BITMAP_COUNT - 1] of Integer;

isActiveImage: Array[0..IMG_COUNT - 1] of Boolean;
isLeftTab: Array[IMG_TAB_NORM_1..IMG_TAB_NORM_1 + PANEL_NUM - 1] of Boolean;

MapDragStartX, MapDragStartY: Integer;

panels: array [IMG_TAB_NORM_1..IMG_TAB_NORM_1 + PANEL_NUM - 1] of TPanel;


procedure OutsideBox(l,t,r,b, obj: integer);
begin
if tImages[obj].Left > l then
tImages[obj].Left := l;
if tImages[obj].Top > t then
tImages[obj].Top := t;
if tImages[obj].Left < r then
tImages[obj].Left := r;
if tImages[obj].Top < b then
tImages[obj].Top := b;
end;

procedure OnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
BoundL, BoundT: Extended;
begin
case sender of
tImages[IMG_LOC_MAP]:
begin
MapDragStartX := x;
MapDragStartY := y;
end;
tImages[IMG_LOC_NAV]:
begin
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x + (x - left), {T} y + (y - top), {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

OutsideBox(0,0,-345, -354, IMG_LOC_MAP);
end;
end;
end;

var
accel, move, senderTab, pan: integer;
cons: array [IMG_TAB_NORM_1..IMG_TAB_NORM_1 + PANEL_NUM - 1] of integer;

procedure TimerTabClick(Sender: TObject);
var
i, e, d, top, bottom: Integer;
begin
d := integer(isLeftTab[senderTab])* 2 - 1;
if isLeftTab[senderTab] then
begin
top := IMG_TAB_NORM_1 + PANEL_NUM - 1
bottom := senderTab + 1;
end else
begin
top := senderTab;
bottom := IMG_TAB_NORM_1
end;

if move = 0 then
for e := bottom to top do
cons[e] := tImages[e].Left;
accel := accel + 2;
move := move + accel;
for i := bottom to top do
if isLeftTab[i] = isLeftTab[senderTab] then
tImages[i].Left := tImages[i].Left + accel * d;
if move >= 377 then
begin
for e := bottom to top do
if isLeftTab[e] = isLeftTab[senderTab] then
begin
tImages[e].Left := cons[e] + 377 * d;
isLeftTab[e] := not isLeftTab[senderTab];
end;
move := 0;
time.ENABLED := false;
end;

if pan < senderTab then
begin
panels[pan].width := panels[pan].width + accel * d;
panels[senderTab].left := panels[senderTab].left + accel * d;
panels[senderTab].width := panels[senderTab].width - accel * d;
end;
if pan > senderTab then
begin
panels[pan].left := panels[pan].left + accel * d;
panels[pan].width := panels[pan].width - accel * d;
panels[senderTab].width := panels[senderTab].width + accel * d;
end;
end;

procedure TabClick(Sender: TObject);
var
i: integer;
begin
if not time.ENABLED then
begin
accel := 0;
time.enabled := not time.enabled;
pan := senderTab;
for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_1 + PANEL_NUM - 1 do
if (Sender = tImages[i]) then
senderTab := i;
end;
end;

procedure LocViewer(Sender: TObject);
var
i: Integer;
am: TintegerArray;
tru: boolean;
begin
am := [IMG_LOC_ICON_NORM, IMG_TAB_HINT, IMG_LOC_LABEL];
case Sender of
tImages[IMG_LOC_ICON_NORM]: tru := true;
tImages[IMG_LOC_EXIT_NORM]: tru := false;
end;

for i := IMG_LOC_EXIT_NORM to IMG_LOC_BOX_BOTTOM do
tImages[i].Visible := tru;

for i := 0 to high(am) do
tImages[am[i]].Visible := not tru;
end;

procedure Clicked(Sender: TObject);
var
i: Integer;
begin
for i := 0 to BITMAP_COUNT - 1 do
FreeBitmap(frmBitmaps[i]);
frmMain.ModalResult := mrOk;
end;

procedure MouseMoved(Sender: TObject; Shift: TShiftState; x, y: Integer);
var
hi, i, bmp, xdif, ydif, h: Integer;
BoundL, BoundT: Extended;
imgSwap, bmpArr, imgArr: Array of Integer;
begin
bmpArr := [ X_NORM, Q_NORM, LOAD_TAB_NORM,
SAVE_TAB_NORM, TAB_NORM_1, TAB_NORM_2,
TAB_NORM_3, TAB_NORM_4, TAB_NORM_5, LOC_ICON_NORM, LOC_EXIT_NORM ]

imgArr := [ IMG_X_NORM, IMG_Q_NORM, IMG_LOAD_TAB_NORM,
IMG_SAVE_TAB_NORM, IMG_TAB_NORM_1, IMG_TAB_NORM_2,
IMG_TAB_NORM_3, IMG_TAB_NORM_4, IMG_TAB_NORM_5, IMG_LOC_ICON_NORM, IMG_LOC_EXIT_NORM ]
hi := High(bmpArr);
case Sender of
tImages[IMG_BGND], tImages[IMG_LOC_MAP]:
begin
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;

bmp := frmBitmaps[bmpArr[i]];
DrawBitmap(bmp,tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;
end;
for h := 0 to hi do
case Sender of
tImages[imgArr[h]]:
begin
imgSwap := [imgArr[h], frmBitmaps[bmpArr[h] + 1]];
if not (isActiveImage[imgSwap[0]]) then
begin
DrawBitmap(imgSwap[1],tImages[imgSwap[0]].Canvas,0,0);
isActiveImage[imgSwap[0]] := True;
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;
if (i = imgSwap[0] - 1) then
Continue;
if imgSwap[0] = IMG_LOC_EXIT_NORM then
if (i = imgSwap[0]) then
Continue;
if imgSwap[0] = IMG_LOC_ICON_NORM then
if (i = imgSwap[0] - 10) then
Continue;
bmp := frmBitmaps[bmpArr[i]];
DrawBitmap(bmp, tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;
end;
end;
case sender of
tImages[IMG_LOC_MAP]:
begin
if not IsMouseButtonDown(1) then exit;
xdif := x - MapDragStartX;
ydif := y - MapDragStartY;
tImages[IMG_LOC_MAP].Left := tImages[IMG_LOC_MAP].Left + xdif;
tImages[IMG_LOC_MAP].Top := tImages[IMG_LOC_MAP].Top + ydif;

OutsideBox(0,0,-854, -765, IMG_LOC_MAP);

BoundL := -tImages[IMG_LOC_MAP].Left / 7.234 + 376;
BoundT := -tImages[IMG_LOC_MAP].Top / 7.234 + 216;


with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} Round(BoundL), {T} Round(BoundT), {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);
end;
tImages[IMG_LOC_NAV]:
begin
if not IsMouseButtonDown(1) then exit;
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x - 55 - 100, {T} y - 40 - 100, {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

OutsideBox(0, 0, -854, -765, IMG_LOC_MAP);
end;
end;
end;

procedure OnClickEvents(Sender: TObject);
var i: integer;
begin
for i := 0 to PANEL_NUM - 1 do
case sender of
tImages[IMG_TAB_NORM_1 + i]: TabClick(Sender);
end;
case Sender of
tImages[IMG_X_NORM]: Clicked(Sender);
tImages[IMG_LOC_ICON_NORM], tImages[IMG_LOC_EXIT_NORM]: LocViewer(Sender);
end;
end;

procedure InitForm;
var
i: Integer;
consts: TintegerArray;
bmpArr: TStringArray;
xy: TPointArray;
visibl: TBoolArray;
wh: TPoint;
begin
bmpArr := ['BGND','X_NORM','X_HOVER','Q_NORM','Q_HOVER','LOAD_TAB_NORM','LOAD_TAB_HOVER','SAVE_TAB_NORM','SAVE_TAB_HOVER','TAB_NORM_1','TAB_HOVER_1','TAB_NORM_2','TAB_HOVER_2','TAB_NORM_3','TAB_HOVER_3','TAB_NORM_4','TAB_HOVER_4','TAB_NORM_5','TAB_HOVER_5','LOC_ICON_NORM','LOC_ICON_HOVER','LOC_EXIT_NORM','LOC_EXIT_HOVER','LOC_MAP','LOC_NAV','LOC_BORD_TOP','LOC_BORD_BOTTOM','LOC_BORD_LEFT','LOC_BORD_RIGHT','LOC_BOX_TOP','LOC_BOX_LEFT','LOC_LABEL','TAB_HINT'];
for i := 0 to High(frmBitmaps) do
frmBitmaps[i] := LoadBitmap(ScriptPath + 'Bitmaps\' + bmpArr[i] + '.png');

frmMain := TForm.Create(nil);
frmMain.SetBounds({L} 100, {T} 100, {W} 600, {H} 400);
//frmMain.Position := poScreenCenter;
frmMain.BorderStyle := bsNone;

time := TTimer.Create(frmMain);
with time do
begin
ONTIMER := @TimerTabClick;
INTERVAL := 10;
ENABLED := false;
end;

xy := [Point(0,0), Point(575,7), Point(557,7), Point(7,69), Point(81,69), Point(9, 100), Point(427,100), Point(468,100), Point(509,100), Point(550,100), Point(179,204), Point(475,7), Point(-300,0), Point(369,209), Point(0,0), Point(0,393), Point(0,7), Point(593,7), Point(Round( 300 / 7.234 + 376), 216), Point(Round( 300 / 7.234 + 376), 216 + 1), Point(Round( 300 / 7.234 + 376) + 83, 216 + 1), Point(Round( 300 / 7.234 + 376), 216 + 1 + 54), Point(156,250), Point(208,379)];
visibl := [true, true, true, true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, true, true];
consts := [BGND, X_NORM, Q_NORM, LOAD_TAB_NORM,SAVE_TAB_NORM,TAB_NORM_1, TAB_NORM_2, TAB_NORM_3, TAB_NORM_4, TAB_NORM_5, LOC_ICON_NORM, LOC_EXIT_NORM, LOC_MAP, LOC_NAV, LOC_BORD_TOP, LOC_BORD_BOTTOM, LOC_BORD_LEFT, LOC_BORD_RIGHT, LOC_BOX_TOP, LOC_BOX_LEFT, LOC_BOX_LEFT, LOC_BOX_TOP, LOC_LABEL, TAB_HINT];

for i := low(panels) to high(panels) do
begin
panels[i] := TPanel.Create(frmMain);
panels[i].parent := frmMain;
GetBitmapSize(frmBitmaps[consts[i]], wh.x, wh.y);
panels[i].SetBounds(xy[i].x + wh.x, xy[i].y, 0, wh.y);
end;

for i := 0 to IMG_COUNT - 1 do
begin
if i < 10 then
tImages[i] := TImage.Create(frmMain)
else
tImages[i] := TImage.Create(panels[low(panels)]);
with tImages[i] do
begin
if i < 10 then
Parent := frmMain
else
Parent := panels[low(panels)];
GetBitmapSize(frmBitmaps[consts[i]], wh.x, wh.y);
SetBounds(xy[i].x, xy[i].y, wh.x, wh.y);
OnMouseMove := @MouseMoved;
ONMOUSEDOWN := @OnMouseDown;
OnClick := @OnClickEvents;
isActiveImage[i] := False;
visible := Visibl[i];
end;
DrawBitmap(frmBitmaps[consts[i]], tImages[i].canvas, 0, 0);
end;

isLeftTab[IMG_TAB_NORM_1] := true;
panels[IMG_TAB_NORM_1].width := 378;
tImages[10].BringToFront;
senderTab := IMG_TAB_NORM_1;
end;

procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;

procedure ShowFormModal;
begin
frmMain.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;

begin
try
SafeInitForm;
SafeShowFormModal;
finally
time.ENABLED := false;
time.Free;
frmMain.Free;
except
Writeln(ExceptionToString(ExceptionType, ExceptionParam));
end;
end.

as for the panels, again, they're a place holder. You can just change TPanel to TImage in the declaration and the init parts and it will work exactly the same, just without a background. But since they still don't move correctly, it would just make things harder.

EDIT: crap. i don't know why but i thought i had tested this a while ago and it worked…i guess not. Timages can't be parents of things. So the next best thing is to just do add this to the panel creation part.

panels.BEVELWIDTH := 0;
panels.COLOR := 1909544;

also what did you mean by tab images installed into script?


just put a timage in each of the panels (I like the texture of the background). the image can cover it. oh i just meant i'd roughed the extra images in, with the consts etc. I also had to change some numbers in the swapimg bit (whenever new constants are added before the panel 1 images, the mouseovers for loc_icon etc get messed up).

Dan Cardin

2010-07-16 22:25:39

i honestly cant tell the difference between the textured and untextured backgrounds, but i suppose you can do that once we get everything a-working.

marpis

2010-07-26 07:18:08

I really don't want to see this form die :(
You could actually take off the location viewer if it made finishing this faster.
Just make it have dropdown list for the script.
LIST ITEMS:
Mining
-Powerminer
-Varrock
—East
—West
-Lubridge Swamp
—East
—West
-Rimmington
Woodcutting
-Powercutter
-Varrock
— East
-Draynor
-Port Sarim
-Falador
-Rimmington

After that a checkbox list for items/objects you want to auto.

Dan Cardin

2010-07-26 07:59:43

The map isnt really a big problem. Indeed it needs to be updated to fit the current size, but the big problem is the tab switching bug and the fact that i dont know what you guys want me to add to the other tabs.

Coh3n

2010-07-26 14:08:00

From: Dan Cardin
The map isnt really a big problem. Indeed it needs to be updated to fit the current size, but the big problem is the tab switching bug and the fact that i dont know what you guys want me to add to the other tabs.

Okay, well let's just let the location view be for now. I would rather get all the tabs done first. Here's my idea:
  1. An intro-type slide to MSI? Maybe a sweet poster?
  2. Script setup (this stuff):

  3. const
    BREAK_TIME = 15;
    SAVE_DEBUG = False;

    WORLD_SMART = 152;

    STATS_ID = '';
    STATS_PASS = '';
    May need some decoration to fill the empty spaces, I don't know. I don't even know if the WORLD_SMART is needed since it doesn't actually go the that work anyway.
  4. Player setup with subtabs (or a TListBox). I think tabs look better, but a TListBox is more user-friendly, IMO. Plus the colour/text can be changed to match the form if needed.
  5. Credits + "Thanks for using" banner
Just some ideas.

marpis

2010-07-26 14:27:00

From: Dan Cardin
The map isnt really a big problem. Indeed it needs to be updated to fit the current size, but the big problem is the tab switching bug and the fact that i dont know what you guys want me to add to the other tabs.


Hmm, I personally think the current Location Viewer is a bit clumsy because you'd have to find the locations yourself.

I'd rather have a form like this (just my opinion):
Page 1:
  • List of players
  • Add Player
  • Remove Player
  • Script stats authentication (no need to make functional atm)

Page 2:
  • Dropdown menu on the top-left corner to select player to modify
  • Checkboxlist for which scripts to use

Page 3:
  • Dropdown menu on the top-left corner to select player to modify
  • Checkboxlist for which objects to auto

Page 4:
  • Dropdown menu on the top-left corner to select player to modify
  • Set loads before break and total loads

Page 5:
  • Conclusion: one list that shows (not urgent)
    • Player name
    • Scripts
    • Objects
    • Loads to do etc.
  • Start!
  • Clear All -> Popup: Are you sure? (not urgent)

Coh3n

2010-07-26 14:33:18

Wow marpis, laughed so hard at the Pokemon script. :p <3

Where you have the stats stuff, you'll also have to add the Debug and Break time constants. A "?" beside the entries that my be confusing would be nice also (I do this in my draynor form).

Dan Cardin

2010-07-26 18:15:25

i was thinking of type thing to do the players stuff. More consolidated imo. But i suppose as more scripts and options get added, spreading it out as you do may be better. I think, if using your version, adding a next button next to the drop down for quicker switching and a Label on the right with the player name to make it easier to see quickly. To me the dropdown should just be for switching between players that arent next to each other, not for identification of which player you're adding (at least primarily)

Wizzup?

2010-07-26 18:23:54

Wow. The forms are looking terrific…! :)

ReadySteadyGo

2010-07-26 18:43:41

From: Dan Cardin
i was thinking of type thing to do the players stuff. More consolidated imo. But i suppose as more scripts and options get added, spreading it out as you do may be better. I think, if using your version, adding a next button next to the drop down for quicker switching and a Label on the right with the player name to make it easier to see quickly. To me the dropdown should just be for switching between players that arent next to each other, not for identification of which player you're adding (at least primarily)


If you want to do wireframes Cardin I will design the panels and upload the .png's. We should use Timages to fit the rest of the design.

I disagree with the next button. What about Tabs that are draggable to change the position etc.?

Coh3n

2010-07-26 18:45:37

From: ReadySteadyGo
If you want to do wireframes Cardin I will design the panels and upload the .png's. We should use Timages to fit the rest of the design.

I think he was just showing his opinion for a general layout.

ReadySteadyGo

2010-07-26 18:55:53

Yeah. Badly phrased. I was more just offering to do the graphics to fit the main design when the panels gets made.

From: marpis
Hmm, I personally think the current Location Viewer is a bit clumsy because you'd have to find the locations yourself.


The original point of the location viewer has been changed for some reason. It is not for selecting the location. It is simply a tool for viewing the routes and locations (with arrows etc) it might also have additional information and hopefully there will be an interactive legend system which the user can narrow down what his/her search. It should not have been moved into a panel, which just changes it's purpose. It isn't a step. It's an add on utility.

Good read:
http://developer.apple.com/mac/library/documentation/UserExperience/Conceptual/AppleHIGuidelines/XHIGIntro/XHIGIntro.html

Dan Cardin

2010-07-26 21:57:09

Putting it in tab,imo, makes it more integrated with the way the whole rest of the form works. Out of tab breaks consistency but indeed makes it much easier to use.

As for tabs, tabs seem like something that you want to be able to switch back and forth between all the time and such. That's why browsers and text editors use them. I would think that once you set up your chars, you're not going to be spending time switching between them all. So i think the dropdown will work well for finding specific players, and next and back button will work for just going through the list.

Sir R. M8gic1an

2010-07-27 11:47:35

If the map is an utility then you should have the choice to only open it if you want to.

I like the way ReadySteadyGo is going about it by saying that the scripts should be "represented" on the map, so that you have a visual check of what scripts there are.

As for the NextPlayer button I agree with Dan, I find it much smoother to click Next Player rather than dragging a tab as RSG suggested.

Loved marpis general layout, I'd suggest working around that and adding and adjusting whatever else needs to be in there.

Looking good :)

~RM

Dan Cardin

2010-07-27 20:30:58

I disagree a little. To me, if the map is supposed to be informational, then why both even having the button to open it. Give it its own tab, and have it be the first tab. Everyone will see it and if its not their first time using the form and dont care, then they can skip it. This is all assuming that we are indeed adapting it for tab inclusiveness. If not, then this won't apply.

and i started making the actual form stuff. Well i made it all, and just started making some of it work

program MSIForm;

const
IMG_COUNT = 24;
// Used in frmMain
IMG_BGND = 0;
IMG_X_NORM = 1;
IMG_Q_NORM = 2;
IMG_LOAD_TAB_NORM = 3;
IMG_SAVE_TAB_NORM = 4;
IMG_TAB_NORM_1 = 5;
IMG_TAB_NORM_2 = 6;
IMG_TAB_NORM_3 = 7;
IMG_TAB_NORM_4 = 8;
IMG_TAB_NORM_5 = 9;

// Used in Panel 0 (Is also used for frmMain)
IMG_LOC_ICON_NORM = 10;
IMG_LOC_EXIT_NORM = 11;
IMG_LOC_MAP = 12;
IMG_LOC_NAV = 13;
IMG_LOC_BORD_TOP = 14;
IMG_LOC_BORD_BOTTOM = 15;
IMG_LOC_BORD_LEFT = 16;
IMG_LOC_BORD_RIGHT = 17;
IMG_LOC_BOX_TOP = 18;
IMG_LOC_BOX_LEFT = 19;
IMG_LOC_BOX_RIGHT = 20;
IMG_LOC_BOX_BOTTOM = 21;

IMG_LOC_LABEL = 22;
IMG_TAB_HINT = 23;

PANEL_NUM = 5;
// Used in Panel 1

// Used in Panel 2

// Used in Panel 3

// Used in Panel 4

BITMAP_COUNT = 33;
BGND = 0;
X_NORM = 1;
X_HOVER = 2;
Q_NORM = 3;
Q_HOVER = 4;
LOAD_TAB_NORM = 5;
LOAD_TAB_HOVER = 6;
SAVE_TAB_NORM = 7;
SAVE_TAB_HOVER = 8;
TAB_NORM_1 = 9;
TAB_HOVER_1 = 10;
TAB_NORM_2 = 11;
TAB_HOVER_2 = 12;
TAB_NORM_3 = 13;
TAB_HOVER_3 = 14;
TAB_NORM_4 = 15;
TAB_HOVER_4 = 16;
TAB_NORM_5 = 17;
TAB_HOVER_5 = 18;
LOC_ICON_NORM = 19;
LOC_ICON_HOVER = 20;
LOC_EXIT_NORM = 21;
LOC_EXIT_HOVER = 22;
LOC_MAP = 23;
LOC_NAV = 24;
LOC_BORD_TOP = 25;
LOC_BORD_BOTTOM = 26;
LOC_BORD_LEFT = 27;
LOC_BORD_RIGHT = 28;
LOC_BOX_TOP = 29;
LOC_BOX_LEFT = 30;
LOC_LABEL = 31;
TAB_HINT = 32;

var
frmMain: TForm;
time: TTimer;

tImages: Array[0..IMG_COUNT - 1] of TImage;

frmBitmaps: Array [0..BITMAP_COUNT - 1] of Integer;

isActiveImage: Array[0..IMG_COUNT - 1] of Boolean;
isLeftTab: Array[IMG_TAB_NORM_1..IMG_TAB_NORM_1 + PANEL_NUM - 1] of Boolean;

MapDragStartX, MapDragStartY: Integer;

panels: array [IMG_TAB_NORM_1..IMG_TAB_NORM_1 + PANEL_NUM - 1] of TPanel;





var //Panel 2
CheckListBox1: TCheckListBox;
LabeledEdit1, LabeledEdit: TEdit;
Button1,Button2: TButton;
var //Panel 3
Label_3: TLabel;
ComboBox_3: TComboBox;
Add_3, Delete_3: TButton;
CheckListBox_3: TCheckListBox;
var //Panel 4
Label_4: TLabel;
ComboBox_4: TComboBox;
Add_4, Delete_4: TButton;
CheckListBox_4: TCheckListBox;
var //Panel 5
Label_5, Label2_5: TLabel;
ComboBox_5: TComboBox;
Add_5, Delete_5: TButton;
Edit_5, Edit2_5: TEdit;


procedure OutsideBox(l,t,r,b, obj: integer);
begin
if tImages[obj].Left > l then
tImages[obj].Left := l;
if tImages[obj].Top > t then
tImages[obj].Top := t;
if tImages[obj].Left < r then
tImages[obj].Left := r;
if tImages[obj].Top < b then
tImages[obj].Top := b;
end;

procedure OnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
BoundL, BoundT: Extended;
begin
case sender of
tImages[IMG_LOC_MAP]:
begin
MapDragStartX := x;
MapDragStartY := y;
end;
tImages[IMG_LOC_NAV]:
begin
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x + (x - left), {T} y + (y - top), {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

OutsideBox(0,0,-345, -354, IMG_LOC_MAP);
end;
end;
end;

var
accel, move, senderTab, pan: integer;
cons: array [IMG_TAB_NORM_1..IMG_TAB_NORM_1 + PANEL_NUM - 1] of integer;

procedure TimerTabClick(Sender: TObject);
var
i, e, d, top, bottom: Integer;
begin
d := integer(isLeftTab[senderTab])* 2 - 1;
if isLeftTab[senderTab] then
begin
top := IMG_TAB_NORM_1 + PANEL_NUM - 1
bottom := senderTab + 1;
end else
begin
top := senderTab;
bottom := IMG_TAB_NORM_1
end;

if move = 0 then
for e := bottom to top do
cons[e] := tImages[e].Left;
accel := accel + 2;
move := move + accel;
for i := bottom to top do
if isLeftTab[i] = isLeftTab[senderTab] then
tImages[i].Left := tImages[i].Left + accel * d;
if move >= 377 then
begin
for e := bottom to top do
if isLeftTab[e] = isLeftTab[senderTab] then
begin
tImages[e].Left := cons[e] + 377 * d;
isLeftTab[e] := not isLeftTab[senderTab];
end;
move := 0;
time.ENABLED := false;
end;

if pan < senderTab then
begin
panels[pan].width := panels[pan].width + accel * d;
panels[senderTab].left := panels[senderTab].left + accel * d;
panels[senderTab].width := panels[senderTab].width - accel * d;
end;
if pan > senderTab then
begin
panels[pan].left := panels[pan].left + accel * d;
panels[pan].width := panels[pan].width - accel * d;
panels[senderTab].width := panels[senderTab].width + accel * d;
end;
end;

procedure TabClick(Sender: TObject);
var
i: integer;
begin
if not time.ENABLED then
begin
accel := 0;
time.enabled := not time.enabled;
pan := senderTab;
for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_1 + PANEL_NUM - 1 do
if (Sender = tImages[i]) then
senderTab := i;
end;
end;

procedure LocViewer(Sender: TObject);
var
i: Integer;
am: TintegerArray;
tru: boolean;
begin
am := [IMG_LOC_ICON_NORM, IMG_TAB_HINT, IMG_LOC_LABEL];
case Sender of
tImages[IMG_LOC_ICON_NORM]: tru := true;
tImages[IMG_LOC_EXIT_NORM]: tru := false;
end;

for i := IMG_LOC_EXIT_NORM to IMG_LOC_BOX_BOTTOM do
tImages[i].Visible := tru;

for i := 0 to high(am) do
tImages[am[i]].Visible := not tru;
end;

procedure Clicked(Sender: TObject);
var
i: Integer;
begin
for i := 0 to BITMAP_COUNT - 1 do
FreeBitmap(frmBitmaps[i]);
frmMain.ModalResult := mrOk;
end;

procedure MouseMoved(Sender: TObject; Shift: TShiftState; x, y: Integer);
var
hi, i, bmp, xdif, ydif, h: Integer;
BoundL, BoundT: Extended;
imgSwap, bmpArr, imgArr: Array of Integer;
begin
bmpArr := [ X_NORM, Q_NORM, LOAD_TAB_NORM,
SAVE_TAB_NORM, TAB_NORM_1, TAB_NORM_2,
TAB_NORM_3, TAB_NORM_4, TAB_NORM_5, LOC_ICON_NORM, LOC_EXIT_NORM ]

imgArr := [ IMG_X_NORM, IMG_Q_NORM, IMG_LOAD_TAB_NORM,
IMG_SAVE_TAB_NORM, IMG_TAB_NORM_1, IMG_TAB_NORM_2,
IMG_TAB_NORM_3, IMG_TAB_NORM_4, IMG_TAB_NORM_5, IMG_LOC_ICON_NORM, IMG_LOC_EXIT_NORM ]
hi := High(bmpArr);
case Sender of
tImages[IMG_BGND], tImages[IMG_LOC_MAP]:
begin
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;

bmp := frmBitmaps[bmpArr[i]];
DrawBitmap(bmp,tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;
end;
for h := 0 to hi do
case Sender of
tImages[imgArr[h]]:
begin
imgSwap := [imgArr[h], frmBitmaps[bmpArr[h] + 1]];
if not (isActiveImage[imgSwap[0]]) then
begin
DrawBitmap(imgSwap[1],tImages[imgSwap[0]].Canvas,0,0);
isActiveImage[imgSwap[0]] := True;
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;
if (i = imgSwap[0] - 1) then
Continue;
if imgSwap[0] = IMG_LOC_EXIT_NORM then
if (i = imgSwap[0]) then
Continue;
if imgSwap[0] = IMG_LOC_ICON_NORM then
if (i = imgSwap[0] - 10) then
Continue;
bmp := frmBitmaps[bmpArr[i]];
DrawBitmap(bmp, tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;
end;
end;
case sender of
tImages[IMG_LOC_MAP]:
begin
if not IsMouseButtonDown(1) then exit;
xdif := x - MapDragStartX;
ydif := y - MapDragStartY;
tImages[IMG_LOC_MAP].Left := tImages[IMG_LOC_MAP].Left + xdif;
tImages[IMG_LOC_MAP].Top := tImages[IMG_LOC_MAP].Top + ydif;

OutsideBox(0,0,-854, -765, IMG_LOC_MAP);

BoundL := -tImages[IMG_LOC_MAP].Left / 7.234 + 376;
BoundT := -tImages[IMG_LOC_MAP].Top / 7.234 + 216;


with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} Round(BoundL), {T} Round(BoundT), {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);
end;
tImages[IMG_LOC_NAV]:
begin
if not IsMouseButtonDown(1) then exit;
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x - 55 - 100, {T} y - 40 - 100, {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

OutsideBox(0, 0, -854, -765, IMG_LOC_MAP);
end;
end;
end;

procedure OnClickEvents(Sender: TObject);
var i: integer;
begin
for i := 0 to PANEL_NUM - 1 do
case sender of
tImages[IMG_TAB_NORM_1 + i]: TabClick(Sender);
end;
case Sender of
tImages[IMG_X_NORM]: Clicked(Sender);
tImages[IMG_LOC_ICON_NORM], tImages[IMG_LOC_EXIT_NORM]: LocViewer(Sender);
end;
end;

procedure Panel2Clicks(Sender: TObject);
var sel: integer;
begin
case sender of
Button1: begin
ChecklistBox1.ITEMS.Append(LabeledEdit.TEXT + ' (' + LabeledEdit1.TEXT + ')');
checklistbox1.Checked[Checklistbox1.items.Count - 1] := true;
CheckListBox1.ItemIndex := Checklistbox1.items.Count - 1;
end;
Button2: begin
if CheckListbox1.ITEMINDEX >= 0 then
sel := CheckListBox1.ITEMINDEX;
CheckListBox1.ITEMS.Delete(sel);
if sel = 0 then
sel := 1;
CheckListBox1.ItemIndex := sel - 1;
end;
end;
end;

procedure InitForm;
var
i: Integer;
consts: TintegerArray;
bmpArr: TStringArray;
xy: TPointArray;
visibl: TBoolArray;
wh: TPoint;
begin
bmpArr := ['BGND','X_NORM','X_HOVER','Q_NORM','Q_HOVER','LOAD_TAB_NORM','LOAD_TAB_HOVER','SAVE_TAB_NORM','SAVE_TAB_HOVER','TAB_NORM_1','TAB_HOVER_1','TAB_NORM_2','TAB_HOVER_2','TAB_NORM_3','TAB_HOVER_3','TAB_NORM_4','TAB_HOVER_4','TAB_NORM_5','TAB_HOVER_5','LOC_ICON_NORM','LOC_ICON_HOVER','LOC_EXIT_NORM','LOC_EXIT_HOVER','LOC_MAP','LOC_NAV','LOC_BORD_TOP','LOC_BORD_BOTTOM','LOC_BORD_LEFT','LOC_BORD_RIGHT','LOC_BOX_TOP','LOC_BOX_LEFT','LOC_LABEL','TAB_HINT'];
for i := 0 to High(frmBitmaps) do
frmBitmaps[i] := LoadBitmap(ScriptPath + 'Bitmaps\' + bmpArr[i] + '.png');

frmMain := TForm.Create(nil);
frmMain.SetBounds({L} 100, {T} 100, {W} 600, {H} 400);
//frmMain.Position := poScreenCenter;
frmMain.BorderStyle := bsNone;

time := TTimer.Create(frmMain);
with time do
begin
ONTIMER := @TimerTabClick;
INTERVAL := 10;
ENABLED := false;
end;

xy := [Point(0,0), Point(575,7), Point(557,7), Point(7,69), Point(81,69), Point(9, 100), Point(427,100), Point(468,100), Point(509,100), Point(550,100), Point(179,204), Point(475,7), Point(-300,0), Point(369,209), Point(0,0), Point(0,393), Point(0,7), Point(593,7), Point(Round( 300 / 7.234 + 376), 216), Point(Round( 300 / 7.234 + 376), 216 + 1), Point(Round( 300 / 7.234 + 376) + 83, 216 + 1), Point(Round( 300 / 7.234 + 376), 216 + 1 + 54), Point(156,250), Point(208,379)];
visibl := [true, true, true, true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, true, true];
consts := [BGND, X_NORM, Q_NORM, LOAD_TAB_NORM,SAVE_TAB_NORM,TAB_NORM_1, TAB_NORM_2, TAB_NORM_3, TAB_NORM_4, TAB_NORM_5, LOC_ICON_NORM, LOC_EXIT_NORM, LOC_MAP, LOC_NAV, LOC_BORD_TOP, LOC_BORD_BOTTOM, LOC_BORD_LEFT, LOC_BORD_RIGHT, LOC_BOX_TOP, LOC_BOX_LEFT, LOC_BOX_LEFT, LOC_BOX_TOP, LOC_LABEL, TAB_HINT];

for i := low(panels) to high(panels) do
begin
panels[i] := TPanel.Create(frmMain);
panels[i].parent := frmMain;
GetBitmapSize(frmBitmaps[consts[i]], wh.x, wh.y);
panels[i].SetBounds(xy[i].x + wh.x, xy[i].y, 0, wh.y);
end;

for i := 0 to IMG_COUNT - 1 do
begin
if i < 10 then
tImages[i] := TImage.Create(frmMain)
else
tImages[i] := TImage.Create(panels[low(panels)]);
with tImages[i] do
begin
if i < 10 then
Parent := frmMain
else
Parent := panels[low(panels)];
GetBitmapSize(frmBitmaps[consts[i]], wh.x, wh.y);
SetBounds(xy[i].x, xy[i].y, wh.x, wh.y);
OnMouseMove := @MouseMoved;
ONMOUSEDOWN := @OnMouseDown;
OnClick := @OnClickEvents;
isActiveImage[i] := False;
visible := Visibl[i];
end;
DrawBitmap(frmBitmaps[consts[i]], tImages[i].canvas, 0, 0);
end;



CheckListBox1 := TCheckListBox.Create(panels[IMG_TAB_NORM_2]);
CheckListBox1.Parent := panels[IMG_TAB_NORM_2];
CheckListBox1.SetBounds(24,40,225,241);

LabeledEdit := TEdit.Create(panels[IMG_TAB_NORM_2]);
LabeledEdit.Parent := panels[IMG_TAB_NORM_2];
LabeledEdit.SetBounds(264,128,105,21);
LabeledEdit.Caption := 'Stats Name';

LabeledEdit1 := TEdit.Create(panels[IMG_TAB_NORM_2]);
LabeledEdit1.Parent := panels[IMG_TAB_NORM_2];
LabeledEdit1.SetBounds(264,160,105,21);
LabeledEdit1.Caption := 'Stats Pass';

Button1 := TButton.Create(panels[IMG_TAB_NORM_2]);
Button1.Parent := panels[IMG_TAB_NORM_2];
Button1.Setbounds(24,8,107,25);
Button1.Caption := 'Add Player';
Button1.ONCLICK := @Panel2Clicks;

Button2 := TButton.Create(panels[IMG_TAB_NORM_2]);
Button2.Parent := panels[IMG_TAB_NORM_2];
Button2.SetBounds(144,8,107,25);
Button2.Caption := 'Remove Player';
Button2.OnClick := @Panel2Clicks;







Add_3 := TButton.Create(panels[IMG_TAB_NORM_3]);
Add_3.Parent := panels[IMG_TAB_NORM_3];
Add_3.SetBounds(5,5,73,25);
Add_3.Caption := 'Remove Player';

ComboBox_3 := TComboBox.Create(panels[IMG_TAB_NORM_3]);
ComboBox_3.Parent := panels[IMG_TAB_NORM_3];
ComboBox_3.SetBounds(add_3.left + add_3.width + 5,5,105,21);
ComboBox_3.Text := 'Player';

Delete_3 := TButton.Create(panels[IMG_TAB_NORM_3]);
Delete_3.Parent := panels[IMG_TAB_NORM_3];
Delete_3.SetBounds(ComboBox_3.left + ComboBox_3.width + 5,5,75,25);
Delete_3.Caption := 'Add Player';

Label_3 := TLabel.Create(panels[IMG_TAB_NORM_3]);
Label_3.Parent := panels[IMG_TAB_NORM_3];
Label_3.Setbounds(288,16,32,13);
Label_3.Caption := 'Player Name';

CheckListBox_3 := TCheckListBox.Create(panels[IMG_TAB_NORM_3]);
CheckListBox_3.Parent := panels[IMG_TAB_NORM_3];
CheckListBox_3.SetBounds(8,40,365,245);






Add_4 := TButton.Create(panels[IMG_TAB_NORM_3]);
Add_4.Parent := panels[IMG_TAB_NORM_4];
Add_4.SetBounds(5,5,73,25);
Add_4.Caption := 'Remove Player';

ComboBox_4 := TComboBox.Create(panels[IMG_TAB_NORM_4]);
ComboBox_4.Parent := panels[IMG_TAB_NORM_4];
ComboBox_4.SetBounds(add_4.left + add_4.width + 5,5,105,21);
ComboBox_4.Text := 'Player';

Delete_4 := TButton.Create(panels[IMG_TAB_NORM_4]);
Delete_4.Parent := panels[IMG_TAB_NORM_4];
Delete_4.SetBounds(ComboBox_4.left + ComboBox_4.width + 5,5,75,25);
Delete_4.Caption := 'Add Player';

Label_4 := TLabel.Create(panels[IMG_TAB_NORM_4]);
Label_4.Parent := panels[IMG_TAB_NORM_4];
Label_4.Setbounds(288,16,32,13);
Label_4.Caption := 'Player Name';

CheckListBox_4 := TCheckListBox.Create(panels[IMG_TAB_NORM_4]);
CheckListBox_4.Parent := panels[IMG_TAB_NORM_4];
CheckListBox_4.SetBounds(8,40,365,245);






Add_5 := TButton.Create(panels[IMG_TAB_NORM_5]);
Add_5.Parent := panels[IMG_TAB_NORM_5];
Add_5.SetBounds(5,5,73,25);
Add_5.Caption := 'Remove Player';

ComboBox_5 := TComboBox.Create(panels[IMG_TAB_NORM_5]);
ComboBox_5.Parent := panels[IMG_TAB_NORM_5];
ComboBox_5.SetBounds(add_5.left + add_5.width + 5,5,105,21);
ComboBox_5.Text := 'Player';

Delete_5 := TButton.Create(panels[IMG_TAB_NORM_5]);
Delete_5.Parent := panels[IMG_TAB_NORM_5];
Delete_5.SetBounds(ComboBox_5.left + ComboBox_5.width + 5,5,75,25);
Delete_5.Caption := 'Add Player';

Label_5 := TLabel.Create(panels[IMG_TAB_NORM_5]);
with Label_5 do
begin
Parent := panels[IMG_TAB_NORM_5];
Setbounds(5,Add_5.top + Add_5.height + 10,32,13);
Caption := 'Loads Before Switching Players:';
end;
Edit_5 := TEdit.Create(panels[IMG_TAB_NORM_5]);
with Edit_5 do
begin
Parent := panels[IMG_TAB_NORM_5];
SetBounds(5,Label_5.top + Label_5.height + 4,150,13);
Caption := '';
end;
Label2_5 := TLabel.Create(panels[IMG_TAB_NORM_5]);
with Label2_5 do
begin
Parent := panels[IMG_TAB_NORM_5];
Setbounds(5,Edit_5.top + Edit_5.height + 15,32,13);
Caption := 'Total Loads:';
end;
Edit2_5 := TEdit.Create(panels[IMG_TAB_NORM_5]);
with Edit2_5 do
begin
Parent := panels[IMG_TAB_NORM_5];
SetBounds(5,Label2_5.top + Label2_5.height + 4,150,13);
Caption := '';
end;






isLeftTab[IMG_TAB_NORM_1] := true;
panels[IMG_TAB_NORM_1].width := 378;
tImages[10].BringToFront;
senderTab := IMG_TAB_NORM_1;
end;

procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;

procedure ShowFormModal;
begin
frmMain.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;

begin
try
SafeInitForm;
SafeShowFormModal;
finally
time.ENABLED := false;
time.Free;
frmMain.Free;
except
Writeln(ExceptionToString(ExceptionType, ExceptionParam));
end;
end.

Coh3n

2010-07-27 21:27:50

I would rather see the map as an extra feature. I personally like using the button to open it, and I like how it covered to whole form. Not sure why I liked it so much, just my opinion I guess.

marpis

2010-07-28 04:54:38

The map in the first page can't really play any role in the setup, can it?
Script selector before adding players?

ReadySteadyGo

2010-07-28 17:08:59

From: marpis
The map in the first page can't really play any role in the setup, can it?
Script selector before adding players?


It's not a script selector. It's a utility.

CX gamer

2010-07-29 09:55:28

I wanted to let you guys know that I'm working a form myself, lower your expectiations. :)

EDIT: I can't get simba's debug image window to work. :o
What's wrong with this script?
[PHP]program fail;
begin
displayDebugImgWindow(655, 477);
end.[/PHP]

Dan Cardin

2010-07-29 12:21:29

you dont use the debugimage for forms :\

CX gamer

2010-07-30 04:49:31

True; because there is no form. o.O

I was planning to create a form from scratch using mouse- and keyboard detection.

Well I have ripped those images anyway, so I might as well give them to someone who can use them..
http://www.fileden.com/files/2009/5/10/2436551//runescape_images.rar

I also have the images of 19k items, along with a script to detect and re-color the background for consistency. If anyone wants that, please ask. ;)

Coh3n

2010-08-04 15:38:16

Okay, so let's try to prevent this from dying again. :p Dan, I just looked at the last one you posted and it's looking good, but I have a couple suggestions/questions.
  • You said the grey box was only there temporarily, correct?
  • I think all the tabs should be moved back one. So the player list is on tab one, etc, etc.
  • What do you think about putting the location viewer symbol in the top left corner of the form? Also make it a lot smaller. I'm not sure how it would look, but we can always try it out.
  • Where is says Stats Name/Pass, I think it should say Username, Password. Or, have a pop up form show when you click add player or something.
  • I don't think there should be the Remove/Add player button or Player Name label in the third, forth and fifth tabs. Have the drop down combo box display the player's name.
  • For the tab where the player selects the scripts/objects, I would rather see skill headings that match the theme of the form (similar to those on my DCnB form), then have a drop down check box menu for each heading that contain the possible scripts for that skill.
  • For objects, a similar thing can be done for headings (only displaying headings for the scripts the user chose), then have a dropdown check box menu for all the possible objects for that script (including an option for the default objects).
  • I know it's not the most important thing right now, but it would be nice for that location viewer to be fixed to show on the whole form. Either that or have it temporarily disabled as right now it just seems like a feature that doesn't work. :p
That's all for now. :)

@ReadySteadyGo: Maybe we can add some more people to the SVN so they can commit?

Dan Cardin

2010-08-04 16:47:03

-grey box is still temporary, but in a different way than i thought before.
-yep, that's after the loc viewer gets all sorted out.
- i agree, it befits it more since it is supposed to be a utility and it will make it out of tab, so makes more sense to have it be full size.
-yep, ok
-the buttons are supposed to say next and previous. My bad. I kind of dislike the chombobox as a way to display the player's name personally.
-i need i screenshot because i dont know what you're talking about
-same here
-it is broken. but just don't click on it then. since much of the form's things are incomplete.

I personally was waiting for mastaraymond to get back since Wizzup says that the onclick event for the checklistbox is an error on their side, and i dont want to do anything until i know whether or not we can even use those objects in the form.

EDIT: loc viewer isn't broken, i lied and changed it back to full view in anticipation of other people agreeing and someone making a new icon for it so it looks good when it's moved to the top somewhere.

Coh3n

2010-08-04 16:59:57

From: Dan Cardin
I personally was waiting for mastaraymond to get back since Wizzup says that the onclick event for the checklistbox is an error on their side, and i dont want to do anything until i know whether or not we can even use those objects in the form.

Oh okay, I didn't realize. Well, we can try to get everything else working properly while waiting for that to be fixed I think.

And for the objects/scripts I meant something like:


Sorry about the terrible paint skills. :p The check boxes beside the script names are suppose to be part of the combo box. The headings would also be a lot more appealable to the eye. :p I also don't know if there would be enough room to do it that way, but it's just an idea.

Dan Cardin

2010-08-04 18:17:43

So just condensing what it is currently into one panel. I think it may or may not work. It might get a bit too much/too big as more skills/places are added eh?

Coh3n

2010-08-04 18:23:12

From: Dan Cardin
So just condensing what it is currently into one panel. I think it may or may not work. It might get a bit too much/too big as more skills/places are added eh?

It wasn't condensing it as the scripts and objects would still be on their individual tabs. I'm just not sure how much I like it all being in a giant text box, unless there's some different things we can do to make it look better. We may not have a choice though because of space.

Dan Cardin

2010-08-04 20:56:41

text box? Well, it will look like marpis's mockup if that's what you mean. If you mean the fact that its all white and such, i dunno. Might be able to do something about that?

Coh3n

2010-08-04 22:30:25

From: Dan Cardin
text box? Well, it will look like marpis's mockup if that's what you mean. If you mean the fact that its all white and such, i dunno. Might be able to do something about that?

Oh sorry, yes I was talking about how it's all white. I thought it was a text box, but I just checked and clearly it's not. :p Also, I'm sure you can change the color of it as I know you can change the color of text boxes/combo boxes etc.

I was just trying to think of a way to avoid having to have such a large box because it doesn't really blend in with the theme of the form.

EDIT: Just checked, and there's no color component in a TCheckListBox, but a subcomponent may have a color component, I'm not sure exactly.

Daniel

2010-08-05 08:03:47

Why not create a RuneScape style combo box using the font characters present in the Simba/SCAR installation? :)

Sir R. M8gic1an

2010-08-05 09:18:49

How abut you 'click' on the skill, it'll 'open up' and show the possible locations, and you can 'click' on it again to 'close it up' ?

~RM

Coh3n

2010-08-05 10:40:34

From: Rasta Magician
How abut you 'click' on the skill, it'll 'open up' and show the possible locations, and you can 'click' on it again to 'close it up' ?

~RM

Oo I like that!

It's not too hard to make another form. I had a few in my Draynor form. All we have to do is make a similar background image for the "subforms" and display the boxes depending on which skill was clicked.

Dan Cardin

2010-08-05 20:47:19

I just think if you have it expandable, then you're run into problems of needing it to scroll if you add a lot of locations and skills and such.

Sir R. M8gic1an

2010-08-05 21:07:37

From: Dan Cardin
I just think if you have it expandable, then you're run into problems of needing it to scroll if you add a lot of locations and skills and such.


I see.

My thoughts: There's only so many skills and so many locations, so maybe, we could just make it expand to the right?

– skill –
– skill –
– skill –

then a person clicks a skill and it becomes

– skill – (checkbox) loc
– (invisible?) – (checkbox) loc
– (invisible?) – (checkbox) loc

so basically expand it to the right :p

~RM

Dan Cardin

2010-08-05 22:23:00

mockup? I personally don't mind how it is now, but if you guys say so, i guess it can be changed. I think though, if we're going to do it like this, it should present itself in basically the same way as the current tabs do in a way. I.E. You click on a skill and everything slides to the left, then a heading saying "Skill Name" and a back button slide in from the right along with the skill's cities and their locs. My only problem is that i think this kind of thing is slower than simply the way marpis suggested it because you have to click through menu's all for 1 player.

Coh3n

2010-08-06 11:05:08

From: Dan Cardin
mockup? I personally don't mind how it is now, but if you guys say so, i guess it can be changed. I think though, if we're going to do it like this, it should present itself in basically the same way as the current tabs do in a way. I.E. You click on a skill and everything slides to the left, then a heading saying "Skill Name" and a back button slide in from the right along with the skill's cities and their locs. My only problem is that i think this kind of thing is slower than simply the way marpis suggested it because you have to click through menu's all for 1 player.

This is true. I don't want it to take forever to setup the players. I guess I just need to see what it would look like the way it is now. If we can blend it in with the general theme of the form, then I'm sure it would be okay.

Sabzi

2010-08-06 17:28:29

I like marpis's idea the most so far. As a user I would totally like it.

Coh3n

2010-08-06 17:36:58

From: Sabzi
I like marpis's idea the most so far. As a user I would totally like it.

Okay. I'd like to see what it would look like. :)

Dan Cardin

2010-08-06 17:50:52

From: Coh3n
Okay. I'd like to see what it would look like. :)


what do you mean?

Coh3n

2010-08-06 18:34:10

From: Dan Cardin
what do you mean?

The way it's setup now (with a check box list, what marpis suggested). The original setup. Like right now it just has a big white box, I'd like to see what it looks like with the skills and their respective scripts, and (hopefully) we can mess with the colors to blend it in with the theme.

Coh3n

2010-08-17 20:03:30

Alright guys, this is close to being done. The rest should be pretty easy. You don't even have to do a lot. Even if you just add one button, that's still good. :) Since ReadySteadyGo seems to have gone inactive, I have made a new SVN with Dan's most recent form script.

https://msiplayerform.googlecode.com/svn/trunk/
Also, the tab plans can be found here.

I'll be able to update the SVN with any changes someone makes, and I'll be more than happy to add you so you can commit, just post your gmail account (or PM me) and I'll make it happen.

CX gamer

2010-08-18 06:40:21

Great! Though I don't think thumbs.db is required. :P

EDIT: Tested it, and it works, mostly. When switching between tabs, sometimes the form isn't rendered correctly.
Also, I'm one of those people who absolutely hates animations.

I didn't know you could load PNG's as bitmaps. :o

Coh3n

2010-08-18 11:21:01

From: CX gamer
Great! Though I don't think thumbs.db is required. :P

EDIT: Tested it, and it works, mostly. When switching between tabs, sometimes the form isn't rendered correctly.
Also, I'm one of those people who absolutely hates animations.

I didn't know you could load PNG's as bitmaps. :o

What do you mean it's not rendering correctly?

And I didn't realize thumbs.db was there, nor do I know what it is. Lol

CX gamer

2010-08-18 12:17:08

Like when switching from 1 to 4 to 2.

Thumbs.db is a file created for your printer so it could print those images more efficiently.

Coh3n

2010-08-18 14:23:46

From: CX gamer
Like when switching from 1 to 4 to 2.

Thumbs.db is a file created for your printer so it could print those images more efficiently.

Can you get a screenshot?

CX gamer

2010-08-18 14:52:21

Example;

Coh3n

2010-08-18 15:02:58

From: CX gamer
Example;

Oh yeah, that's happened to me also. I haven't looked into it by it may be due to the gray panel that covers the different tabs. I'm hoping when that goes away, so will that bug.

CX gamer

2010-08-19 06:34:27

Also, those grey panels could look nicer inho. They could contain some info on what the tab has in storage.

Coh3n

2010-08-19 08:09:52

From: CX gamer
Also, those grey panels could look nicer inho. They could contain some info on what the tab has in storage.

And they will. Oh and just for the record, the grey panels won't actually be there. I think Dan just added them temporarily for some reason (can't remember why).

CX gamer

2010-08-19 08:53:14

Oooh great then! =D

I don't know much about forms, but is it possible to customise the buttons images?

nickrules

2010-08-19 09:00:36

From: CX gamer
Oooh great then! =D

I don't know much about forms, but is it possible to customise the buttons images?



I think so. Or, you can use an image as a button, kind of like what they did with the tabs. not sure if that was helpful, lol :redface:

Coh3n

2010-08-19 12:55:23

From: nickrules
I think so. Or, you can use an image as a button, kind of like what they did with the tabs. not sure if that was helpful, lol :redface:

There's a way, but using images is the best way in my opinion. :) Have one image for the non hovered button and one for when the mouse hovers over it.

Dan Cardin

2010-08-20 16:06:36

The grey boxes will be either covered with an image that's the same as the background or given a color themselves. For example, if after line 450, inside the for loop you add
panels[i].BEVELWIDTH := 0;
panels[i].COLOR := 1909544;
it will look fine imo. I can't tell the difference, but apparently, the background itself isn't a flat color, so it could be the image too. The reason i I havent added that before now is because The panels didnt have anything on them before, so it wouldn't know if they moved in the wrong place like in the bug that you found. But now that they all have form parts on them you can see either way.

So Coh3n - either add those two lines if you cant see the difference either or you can add an image to put on them that's the same as the background (or i can if i have time and you cant.)

Anyone who is willing to look into why the animation goes wrongly when going from certain panels to others please do. I have no idea why it does that, though I'm fairly sure it has to do with one of the global variables directly above TimerTabClick because it works finely when you go in order in either direction.

The the rest of the work is really a lot of switching all of the buttons to images and such. I dont know what everyone's stance is on edit boxes and such; if they will be changed or if they can be changed to images.

Coh3n

2010-08-20 18:29:26

What do you need the grey boxes for to begin with? Can you not just put the components directly on the background image?

ReadySteadyGo

2010-08-20 18:51:32

From: Coh3n
What do you need the grey boxes for to begin with? Can you not just put the components directly on the background image?


That's what I thought but the sliding animation would not work as everything would have to be moved individually. Because you have a panel as the parent component it allows it all to be moved as one.

Coh3n

2010-08-20 18:59:50

From: ReadySteadyGo
That's what I thought but the sliding animation would not work as everything would have to be moved individually. Because you have a panel as the parent component it allows it all to be moved as one.

Couldn't we just change the position/text/visibility of the components depending on which tab we're on? Then again it may just be easier to put the image on the panel.

E: I tried looking for the panel bug but it's hard for me to understand the code since it's not my own and it's so large, but it seems to be only tabs 2 and 3 that are affected. The rest are fine. :unsure:

E2: No offense guys, but the naming of variables needs to be better. I'm honestly lost trying to understand this code. Some are good, like senderTab, but what's pan suppose to mean? currPanel? activePanel? panDirection? There are several possibilities. Also, comments every now and then wouldn't hurt. ;)

Dan Cardin

2010-08-21 10:02:37

currPanel and activePanel i would think are obvious though i dont see them anywhere and panDirection isn't in the latest version either, i think. pan holds the previous value of sendertab before it's changed to the currently clicked tab. I can change it to tsenderTab if you'd like or prevTab or something like that.

the problem has to do with pan being set as far as i can tell. I think at the end of the function it deems pan as < or > than senderTab when it's not and does the wrong one. And that would happen because you are switching directions. but why it does it there and not when you switch directions when going in order, i dont know.

Coh3n

2010-08-21 10:12:36

From: Dan Cardin
currPanel and activePanel i would think are obvious though i dont see them anywhere and panDirection isn't in the latest version either, i think. pan holds the previous value of sendertab before it's changed to the currently clicked tab. I can change it to tsenderTab if you'd like or prevTab or something like that.

the problem has to do with pan being set as far as i can tell. I think at the end of the function it deems pan as < or > than senderTab when it's not and does the wrong one. And that would happen because you are switching directions. but why it does it there and not when you switch directions when going in order, i dont know.

None of the variable names I said in my last post are in the script, I just made them up because the var names now could be interpreted as any one of those.

I'll have to look into the pan var more, but yeah it seems that panel 2/3 aren't being set properly at some point.

Dan Cardin

2010-08-21 10:18:58

None of the variable names I said in my last post are in the script, I just made them up because the var names now could be interpreted as any one of those.

oh! get it it. i skipped over "There are several possiblities" and read it wrong :).

and the problem is not what i thought it might be. It makes no sense!

Coh3n

2010-08-21 10:22:17

From: Dan Cardin
oh! get it it. i skipped over "There are several possiblities" and read it wrong :).

and the problem is not what i thought it might be. It makes no sense!

I wonder if there's a way we can make it work without using global variables. Something could be going wrong there. From what I can tell, the two functions that handle the tab clicking are TimerTabClick and TabClick (unless the global vars are used somewhere else?), but if we can combine them, we should be able to make it work for every tab without having to use so many global vars.

Dan Cardin

2010-08-21 11:03:32

well you could combine them, but that wouldn't change the global variables in itself because tabclick is the actual tabs being clicked and timertabclick is the ontimer event for the timer. It would just involve adding a case to combine them, but i think that that is messier.

accel, move, senderTab, and pan need to be global.accel needs to be incremented every interval of the timer. etc. They all need to be consistent but if they weren't global then they'd reset every interval of the timer and it wouldn't work.

I suppose you could figure out the number of moves it takes to get passed 377 then repurpose one move to only increment 1 per interval then you could base accel off the number of moves that have happened, but that's a lot of work for getting rid of one variable. and if the widths change it would need to be manually found again.

What would work better is making an array of ints to hold the variables or two tpoints, but that would make the variables infinitely less descriptive than they are now.

EDIT: and there is a flaw somewhere in my code that's making it not work. I very much doubt that those variables are being used elsewhere.

Coh3n

2010-08-21 11:07:07

From: Dan Cardin
well you could combine them, but that wouldn't change the global variables in itself because tabclick is the actual tabs being clicked and timertabclick is the ontimer event for the timer. It would just involve adding a case to combine them, but i think that that is messier.

accel, move, senderTab, and pan need to be global.accel needs to be incremented every interval of the timer. etc. They all need to be consistent but if they weren't global then they'd reset every interval of the timer and it wouldn't work.

I suppose you could figure out the number of moves it takes to get passed 377 then repurpose one move to only increment 1 per interval then you could base accel off the number of moves that have happened, but that's a lot of work for getting rid of one variable. and if the widths change it would need to be manually found again.

What would work better is making an array of ints to hold the variables or two tpoints, but that would make the variables infinitely less descriptive than they are now.

EDIT: and there is a flaw somewhere in my code that's making it not work. I very much doubt that those variables are being used elsewhere.

Alright and I didn't realize that was part of the TTimer. I've never used TTimers so I don't know exactly how it works. I find it very weird that's it's only tabs 2 and 3 that are affected, and only when you click them with they're on the left. :unsure:

Dan Cardin

2010-08-21 11:19:09

It works either way and on 4 too. It's all the tabs in the middle. If there were 8 tabs, it would be 2-7 that were affected.

What I don't get is that it only holds the currently clicked tab and the currently showing tab. When you go in order and go from 2 to 3 it works. but when you go out of order like1-2-3-4-2-3 (if you dont go in order like that it gets screwed up not on 2-3) then it doesnt work. I dont get why it works going 2-3 in order but not out of order since the only info the functions should have should be the same.

Coh3n

2010-08-21 11:20:45

From: Dan Cardin
It works either way and on 4 too. It's all the tabs in the middle. If there were 8 tabs, it would be 2-7 that were affected.

What I don't get is that it only holds the currently clicked tab and the currently showing tab. When you go in order and go from 2 to 3 it works. but when you go out of order like1-2-3-4-2-3 (if you dont go in order like that it gets screwed up not on 2-3) then it doesnt work. I dont get why it works going 2-3 in order but not out of order since the only info the functions should have should be the same.

Yeah, that's why I was so confused. I looked at it a lot yesterday, but if I get more time I can try again, I'm just pretty busy right now.

Sir R. M8gic1an

2010-09-03 07:32:06

What's the status on this?

~RM

Coh3n

2010-09-03 14:28:04

From: Sir R. Magician
What's the status on this?

~RM

There's a bug in the tab sliding when all the tabs are on the right. If you try to go to tab 2 or 3, you'll see what I mean. Both Dan and I have looked and we can't figure out why this happens.

Also, Dan mentioned something about Simba not supporting TCheckListBoxes (or whatever they are), so that part can't really be done. There are still several things that can be made, however.
  • The saving/loading of players.
  • Adding players and choosing them from the lists from the different tabs.
  • The location viewer.
  • Basically everything except the TCheckBoxList.

Dan Cardin

2010-09-03 16:47:05

You are currently actually able to add players to the checklistbox. The point of clicking was for when you wanted to click on a player and edit their name or password, which wont work. I am just very lazy. This is not the part of the form that I enjoy making. I like building it. Adding functionality to everything should be everyone else's jobs! lol.

Though that probably means i should get around to moving the loc viewer off tab and moving everything else back a tab, but i have lots of stuff to do, so i may not be able to in the near future.

Dan Cardin

2010-09-14 20:42:29

Well, annoyingly, my previous version of this post got delete, so…i fixed some stuff, added some stuff, and could probably make some stuff shorter, but i would need to know if people cared if the player you have selected on one panel is the player selected on all panels. It would make it easier to program, but a panel wouldn't keep the same player you were on when you left it, if you changed the player on a different panel.

Not that I have looked at it again, but the weird animation bug still eludes me.

program MSIForm;

const
IMG_COUNT = 24;
// Used in frmMain
IMG_BGND = 0;
IMG_X_NORM = 1;
IMG_Q_NORM = 2;
IMG_LOAD_TAB_NORM = 3;
IMG_SAVE_TAB_NORM = 4;
IMG_TAB_NORM_1 = 5;
IMG_TAB_NORM_2 = 6;
IMG_TAB_NORM_3 = 7;
IMG_TAB_NORM_4 = 8;
IMG_TAB_NORM_5 = 9;

// Used in Panel 0 (Is also used for frmMain)
IMG_LOC_ICON_NORM = 10;
IMG_LOC_EXIT_NORM = 11;
IMG_LOC_MAP = 12;
IMG_LOC_NAV = 13;
IMG_LOC_BORD_TOP = 14;
IMG_LOC_BORD_BOTTOM = 15;
IMG_LOC_BORD_LEFT = 16;
IMG_LOC_BORD_RIGHT = 17;
IMG_LOC_BOX_TOP = 18;
IMG_LOC_BOX_LEFT = 19;
IMG_LOC_BOX_RIGHT = 20;
IMG_LOC_BOX_BOTTOM = 21;

IMG_LOC_LABEL = 22;
IMG_TAB_HINT = 23;

PANEL_NUM = 4;
// Used in Panel 1

// Used in Panel 2

// Used in Panel 3

// Used in Panel 4

BITMAP_COUNT = 33;
BGND = 0;
X_NORM = 1;
X_HOVER = 2;
Q_NORM = 3;
Q_HOVER = 4;
LOAD_TAB_NORM = 5;
LOAD_TAB_HOVER = 6;
SAVE_TAB_NORM = 7;
SAVE_TAB_HOVER = 8;
TAB_NORM_1 = 9;
TAB_HOVER_1 = 10;
TAB_NORM_2 = 11;
TAB_HOVER_2 = 12;
TAB_NORM_3 = 13;
TAB_HOVER_3 = 14;
TAB_NORM_4 = 15;
TAB_HOVER_4 = 16;
TAB_NORM_5 = 17;
TAB_HOVER_5 = 18;
LOC_ICON_NORM = 19;
LOC_ICON_HOVER = 20;
LOC_EXIT_NORM = 21;
LOC_EXIT_HOVER = 22;
LOC_MAP = 23;
LOC_NAV = 24;
LOC_BORD_TOP = 25;
LOC_BORD_BOTTOM = 26;
LOC_BORD_LEFT = 27;
LOC_BORD_RIGHT = 28;
LOC_BOX_TOP = 29;
LOC_BOX_LEFT = 30;
LOC_LABEL = 31;
TAB_HINT = 32;

var
frmMain: TForm;
time: TTimer;

tImages: Array[0..IMG_COUNT - 1] of TImage;

frmBitmaps: Array [0..BITMAP_COUNT - 1] of Integer;

isActiveImage: Array[0..IMG_COUNT - 1] of Boolean;
isLeftTab: Array[IMG_TAB_NORM_1..IMG_TAB_NORM_1 + PANEL_NUM - 1] of Boolean;

MapDragStartX, MapDragStartY: Integer;

panels: array [IMG_TAB_NORM_1..IMG_TAB_NORM_1 + PANEL_NUM - 1] of TPanel;





var //Panel 2
UserList: TCheckListBox;
User, Pass: TEdit;
Button1,Button2: TButton;
Label_2, label2_2: TLabel;
var //Panel 3
Label_3: TLabel;
ComboBox_3: TComboBox;
Add_3, Delete_3: TButton;
CheckListBox_3: TCheckListBox;
var //Panel 4
Label_4: TLabel;
ComboBox_4: TComboBox;
Add_4, Delete_4: TButton;
CheckListBox_4: TCheckListBox;
var //Panel 5
Label_5, Label2_5: TLabel;
ComboBox_5: TComboBox;
Add_5, Delete_5: TButton;
Edit_5, Edit2_5: TEdit;


procedure OutsideBox(l,t,r,b, obj: integer);
begin
if tImages[obj].Left > l then
tImages[obj].Left := l;
if tImages[obj].Top > t then
tImages[obj].Top := t;
if tImages[obj].Left < r then
tImages[obj].Left := r;
if tImages[obj].Top < b then
tImages[obj].Top := b;
end;

procedure OnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
BoundL, BoundT: Extended;
begin
case sender of
tImages[IMG_LOC_MAP]:
begin
MapDragStartX := x;
MapDragStartY := y;
end;
tImages[IMG_LOC_NAV]:
begin
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x + (x - left), {T} y + (y - top), {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

OutsideBox(0,0,-345, -354, IMG_LOC_MAP);
end;
end;
end;

var
accel, move, senderTab, pan: integer;
cons: array [IMG_TAB_NORM_1..IMG_TAB_NORM_1 + PANEL_NUM - 1] of integer;

procedure TimerTabClick(Sender: TObject);
var
i, e, d, top, bottom: Integer;
begin
d := integer(isLeftTab[senderTab])* 2 - 1;
if isLeftTab[senderTab] then
begin
top := IMG_TAB_NORM_1 + PANEL_NUM - 1
bottom := senderTab + 1;
end else
begin
top := senderTab;
bottom := IMG_TAB_NORM_1
end;

if move = 0 then
for e := bottom to top do
cons[e] := tImages[e].Left;
accel := accel + 2;
move := move + accel;
for i := bottom to top do
if isLeftTab[i] = isLeftTab[senderTab] then
tImages[i].Left := tImages[i].Left + accel * d;
if move >= 377 then
begin
for e := bottom to top do
if isLeftTab[e] = isLeftTab[senderTab] then
begin
tImages[e].Left := cons[e] + 377 * d;
isLeftTab[e] := not isLeftTab[senderTab];
end;
time.ENABLED := false;
end;

if pan < senderTab then
begin
panels[pan].width := panels[pan].width - accel;
panels[senderTab].left := panels[senderTab].left - accel;
panels[senderTab].width := panels[senderTab].width + accel;
end;
if pan > senderTab then
begin
panels[pan].left := panels[pan].left + accel;
panels[pan].width := panels[pan].width - accel;
panels[senderTab].width := panels[senderTab].width + accel;
end;
end;

procedure TabClick(Sender: TObject);
var
i: integer;
begin
if not time.ENABLED then
begin
accel := 0;
move := 0;
time.enabled := true;
pan := senderTab;
for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_1 + PANEL_NUM - 1 do
if (Sender = tImages[i]) then
senderTab := i;
end;
end;

procedure LocViewer(Sender: TObject);
var
i: Integer;
am: TintegerArray;
tru: boolean;
begin
am := [IMG_LOC_ICON_NORM, IMG_TAB_HINT, IMG_LOC_LABEL];
case Sender of
tImages[IMG_LOC_ICON_NORM]: begin
tru := true;
for i := low(panels) to high(panels) do
panels[i].visible := false;
end;
tImages[IMG_LOC_EXIT_NORM]: begin
tru := false;
for i := low(panels) to high(panels) do
panels[i].visible := true;
end;
end;

for i := IMG_LOC_EXIT_NORM to IMG_LOC_BOX_BOTTOM do
tImages[i].Visible := tru;

for i := 0 to high(am) do
tImages[am[i]].Visible := not tru;
end;

procedure Clicked(Sender: TObject);
var
i: Integer;
begin
for i := 0 to BITMAP_COUNT - 1 do
FreeBitmap(frmBitmaps[i]);
frmMain.ModalResult := mrOk;
end;

procedure MouseMoved(Sender: TObject; Shift: TShiftState; x, y: Integer);
var
hi, i, bmp, xdif, ydif, h: Integer;
BoundL, BoundT: Extended;
imgSwap, bmpArr, imgArr: Array of Integer;
begin
bmpArr := [ X_NORM, Q_NORM, LOAD_TAB_NORM,
SAVE_TAB_NORM, TAB_NORM_1, TAB_NORM_2,
TAB_NORM_3, TAB_NORM_4, TAB_NORM_5, LOC_ICON_NORM, LOC_EXIT_NORM ]

imgArr := [ IMG_X_NORM, IMG_Q_NORM, IMG_LOAD_TAB_NORM,
IMG_SAVE_TAB_NORM, IMG_TAB_NORM_1, IMG_TAB_NORM_2,
IMG_TAB_NORM_3, IMG_TAB_NORM_4, IMG_TAB_NORM_5, IMG_LOC_ICON_NORM, IMG_LOC_EXIT_NORM ]
hi := High(bmpArr);
case Sender of
tImages[IMG_BGND], tImages[IMG_LOC_MAP]:
begin
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;

bmp := frmBitmaps[bmpArr[i]];
DrawBitmap(bmp,tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;
end;
for h := 0 to hi do
case Sender of
tImages[imgArr[h]]:
begin
imgSwap := [imgArr[h], frmBitmaps[bmpArr[h] + 1]];
if not (isActiveImage[imgSwap[0]]) then
begin
DrawBitmap(imgSwap[1],tImages[imgSwap[0]].Canvas,0,0);
isActiveImage[imgSwap[0]] := True;
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;
if (i = imgSwap[0] - 1) then
Continue;
if imgSwap[0] = IMG_LOC_EXIT_NORM then
if (i = imgSwap[0]) then
Continue;
if imgSwap[0] = IMG_LOC_ICON_NORM then
if (i = imgSwap[0] - 10) then
Continue;
bmp := frmBitmaps[bmpArr[i]];
DrawBitmap(bmp, tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;
end;
end;
case sender of
tImages[IMG_LOC_MAP]:
begin
if not IsMouseButtonDown(1) then exit;
xdif := x - MapDragStartX;
ydif := y - MapDragStartY;
tImages[IMG_LOC_MAP].Left := tImages[IMG_LOC_MAP].Left + xdif;
tImages[IMG_LOC_MAP].Top := tImages[IMG_LOC_MAP].Top + ydif;

OutsideBox(0,0,-854, -765, IMG_LOC_MAP);

BoundL := -tImages[IMG_LOC_MAP].Left / 7.234 + 376;
BoundT := -tImages[IMG_LOC_MAP].Top / 7.234 + 216;


with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} Round(BoundL), {T} Round(BoundT), {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);
end;
tImages[IMG_LOC_NAV]:
begin
if not IsMouseButtonDown(1) then exit;
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x - 55 - 100, {T} y - 40 - 100, {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

OutsideBox(0, 0, -854, -765, IMG_LOC_MAP);
end;
end;
end;

procedure OnClickEvents(Sender: TObject);
var i: integer;
begin
for i := 0 to PANEL_NUM - 1 do
case sender of
tImages[IMG_TAB_NORM_1 + i]: TabClick(Sender);
end;
case Sender of
tImages[IMG_X_NORM]: Clicked(Sender);
tImages[IMG_LOC_ICON_NORM], tImages[IMG_LOC_EXIT_NORM]: LocViewer(Sender);
end;
end;

procedure Panel2Clicks(Sender: TObject);
var sel: integer;
begin
case sender of
Button1: begin
UserList.Items.Append(User.Text + ' (' + Pass.Text + ')');
combobox_3.items.append(User.Text);
combobox_4.items.append(User.Text);
UserList.Checked[UserList.items.Count - 1] := true;
UserList.ItemIndex := UserList.items.Count - 1;
User.Text := '';
Pass.Text := '';
end;
Button2: begin
if UserList.ItemIndex >= 0 then
sel := UserList.ItemIndex;
UserList.Items.Delete(sel);
combobox_3.Items.Delete(sel);
combobox_4.Items.Delete(sel);
if sel = 0 then
sel := 1;
UserList.ItemIndex := sel - 1;
User.Text := '';
Pass.Text := '';
end;
UserList: begin
User.Text := UserList.items.strings[UserList.ItemIndex];
Pass.Text := UserList.items.strings[UserList.ItemIndex];
end;
end;
end;

procedure Panel3Clicks(Sender: TObject);
var sel, i: integer;
begin
case sender of
Add_3: begin
if Combobox_3.ITEMINDEX > 0 then
combobox_3.ItemIndex := combobox_3.ItemIndex - 1;
end;
Combobox_3: begin
end;
Delete_3: begin
if Combobox_3.ITEMINDEX < Combobox_3.ITEMS.Count then
combobox_3.ItemIndex := combobox_3.ItemIndex + 1;
end;
end;
end;

procedure Panel4Clicks(Sender: TObject);
var sel, i: integer;
begin
case sender of
Add_4: begin
if Combobox_4.ITEMINDEX > 0 then
combobox_4.ItemIndex := combobox_4.ItemIndex - 1;
end;
Combobox_4: begin
end;
Delete_4: begin
if Combobox_4.ITEMINDEX < Combobox_4.ITEMS.Count then
combobox_4.ItemIndex := combobox_4.ItemIndex + 1;
end;
end;
end;

procedure Panel2Clic(Sender: TObject; Index: Integer);
begin

end;

procedure InitForm;
var
i, pan: Integer;
consts: TintegerArray;
bmpArr: TStringArray;
xy: TPointArray;
visibl: TBoolArray;
wh: TPoint;
begin
bmpArr := ['BGND','X_NORM','X_HOVER','Q_NORM','Q_HOVER','LOAD_TAB_NORM','LOAD_TAB_HOVER','SAVE_TAB_NORM','SAVE_TAB_HOVER','TAB_NORM_1','TAB_HOVER_1','TAB_NORM_2','TAB_HOVER_2','TAB_NORM_3','TAB_HOVER_3','TAB_NORM_4','TAB_HOVER_4','TAB_NORM_5','TAB_HOVER_5','LOC_ICON_NORM','LOC_ICON_HOVER','LOC_EXIT_NORM','LOC_EXIT_HOVER','LOC_MAP','LOC_NAV','LOC_BORD_TOP','LOC_BORD_BOTTOM','LOC_BORD_LEFT','LOC_BORD_RIGHT','LOC_BOX_TOP','LOC_BOX_LEFT','LOC_LABEL','TAB_HINT'];
for i := 0 to High(frmBitmaps) do
frmBitmaps[i] := LoadBitmap(ScriptPath + 'Bitmaps\' + bmpArr[i] + '.png');

frmMain := TForm.Create(nil);
frmMain.SetBounds({L} 100, {T} 100, {W} 600, {H} 400);
//frmMain.Position := poScreenCenter;
frmMain.BorderStyle := bsNone;

time := TTimer.Create(frmMain);
with time do
begin
ONTIMER := @TimerTabClick;
INTERVAL := 10;
ENABLED := false;
end;

xy := [Point(0,0), Point(575,7), Point(557,7), Point(7,69), Point(81,69), Point(9, 100), Point(427,100), Point(468,100), Point(509,100), Point(550,100), Point(30,10), Point(475,7), Point(-300,0), Point(369,209), Point(0,0), Point(0,393), Point(0,7), Point(593,7), Point(Round( 300 / 7.234 + 376), 216), Point(Round( 300 / 7.234 + 376), 216 + 1), Point(Round( 300 / 7.234 + 376) + 83, 216 + 1), Point(Round( 300 / 7.234 + 376), 216 + 1 + 54), Point(7,52), Point(208,379)];
visibl := [true, true, true, true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, true, true];
consts := [BGND, X_NORM, Q_NORM, LOAD_TAB_NORM,SAVE_TAB_NORM,TAB_NORM_1, TAB_NORM_2, TAB_NORM_3, TAB_NORM_4, TAB_NORM_5, LOC_ICON_NORM, LOC_EXIT_NORM, LOC_MAP, LOC_NAV, LOC_BORD_TOP, LOC_BORD_BOTTOM, LOC_BORD_LEFT, LOC_BORD_RIGHT, LOC_BOX_TOP, LOC_BOX_LEFT, LOC_BOX_LEFT, LOC_BOX_TOP, LOC_LABEL, TAB_HINT];

for i := low(panels) to high(panels) do
begin
panels[i] := TPanel.Create(frmMain);
panels[i].parent := frmMain;
GetBitmapSize(frmBitmaps[consts[i]], wh.x, wh.y);
panels[i].SetBounds(xy[i].x + wh.x, xy[i].y, 0, wh.y);
panels[i].BEVELWIDTH := 0;
panels[i].COLOR := 1909544;
end;

for i := 0 to IMG_COUNT - 1 do
begin
tImages[i] := TImage.Create(frmMain)
with tImages[i] do
begin
Parent := frmMain;
GetBitmapSize(frmBitmaps[consts[i]], wh.x, wh.y);
SetBounds(xy[i].x, xy[i].y, wh.x, wh.y);
OnMouseMove := @MouseMoved;
ONMOUSEDOWN := @OnMouseDown;
OnClick := @OnClickEvents;
isActiveImage[i] := False;
visible := Visibl[i];
end;
DrawBitmap(frmBitmaps[consts[i]], tImages[i].canvas, 0, 0);
end;

pan := IMG_TAB_NORM_1;

UserList := TCheckListBox.Create(panels[pan]);
UserList.Parent := panels[pan];
UserList.SetBounds(24,40,225,241);
//UserList.OnItemClick := @Panel2Clic;

Label_2 := TLabel.Create(panels[pan]);
Label_2.Parent := panels[pan];
Label_2.Setbounds(260,50,50,13);
Label_2.Caption := 'Username';

User := TEdit.Create(panels[pan]);
User.Parent := panels[pan];
User.SetBounds(260,Label_2.top + Label_2.height + 4,105,21);

Label2_2 := TLabel.Create(panels[pan]);
Label2_2.Parent := panels[pan];
Label2_2.Setbounds(260,User.top + User.height + 10,32,13);
Label2_2.Caption := 'Password';

Pass := TEdit.Create(panels[pan]);
Pass.Parent := panels[pan];
Pass.SetBounds(260,Label2_2.top + Label2_2.height + 4,105,21);

Button1 := TButton.Create(panels[pan]);
Button1.Parent := panels[pan];
Button1.Setbounds(24,8,107,25);
Button1.Caption := 'Add Player';
Button1.ONCLICK := @Panel2Clicks;

Button2 := TButton.Create(panels[pan]);
Button2.Parent := panels[pan];
Button2.SetBounds(144,8,107,25);
Button2.Caption := 'Remove Player';
Button2.OnClick := @Panel2Clicks;





pan := IMG_TAB_NORM_2;

Add_3 := TButton.Create(panels[pan]);
Add_3.Parent := panels[pan];
Add_3.SetBounds(5,5,73,25);
Add_3.Caption := 'Previous';
Add_3.OnClick := @Panel3Clicks;

ComboBox_3 := TComboBox.Create(panels[pan]);
ComboBox_3.Parent := panels[pan];
ComboBox_3.SetBounds(add_3.left + add_3.width + 5,5,105,21);
ComboBox_3.Text := 'Player';
ComboBox_3.OnClick := @Panel3Clicks;

Delete_3 := TButton.Create(panels[pan]);
Delete_3.Parent := panels[pan];
Delete_3.SetBounds(ComboBox_3.left + ComboBox_3.width + 5,5,75,25);
Delete_3.Caption := 'Next';
Delete_3.OnClick := @Panel3Clicks;

CheckListBox_3 := TCheckListBox.Create(panels[pan]);
CheckListBox_3.Parent := panels[pan];
CheckListBox_3.SetBounds(8,40,365,245);
CheckListBox_3.Items.Append('Woodcutting');
CheckListBox_3.Items.Append('---Varrok East');
CheckListBox_3.Items.Append('---Draynor');
CheckListBox_3.Items.Append('---Port Sarim');
CheckListBox_3.Items.Append('Mining');
CheckListBox_3.Items.Append('---Lumbridge Swamp');
CheckListBox_3.Items.Append('------East');
CheckListBox_3.Items.Append('------West');




pan := IMG_TAB_NORM_3;

Add_4 := TButton.Create(panels[pan]);
Add_4.Parent := panels[pan];
Add_4.SetBounds(5,5,73,25);
Add_4.Caption := 'Previous';
Add_4.OnClick := @Panel4Clicks;

ComboBox_4 := TComboBox.Create(panels[pan]);
ComboBox_4.Parent := panels[pan];
ComboBox_4.SetBounds(add_4.left + add_4.width + 5,5,105,21);
ComboBox_4.Text := 'Player';
ComboBox_4.OnClick := @Panel4Clicks;

Delete_4 := TButton.Create(panels[pan]);
Delete_4.Parent := panels[pan];
Delete_4.SetBounds(ComboBox_4.left + ComboBox_4.width + 5,5,75,25);
Delete_4.Caption := 'Next';
Delete_4.OnClick := @Panel4Clicks;

CheckListBox_4 := TCheckListBox.Create(panels[pan]);
CheckListBox_4.Parent := panels[pan];
CheckListBox_4.SetBounds(8,40,365,245);




pan := IMG_TAB_NORM_4;

Add_5 := TButton.Create(panels[pan]);
Add_5.Parent := panels[pan];
Add_5.SetBounds(5,5,73,25);
Add_5.Caption := 'Previous';

ComboBox_5 := TComboBox.Create(panels[pan]);
ComboBox_5.Parent := panels[pan];
ComboBox_5.SetBounds(add_5.left + add_5.width + 5,5,105,21);
ComboBox_5.Text := 'Player';

Delete_5 := TButton.Create(panels[pan]);
Delete_5.Parent := panels[pan];
Delete_5.SetBounds(ComboBox_5.left + ComboBox_5.width + 5,5,75,25);
Delete_5.Caption := 'Next';

Label_5 := TLabel.Create(panels[pan]);
with Label_5 do
begin
Parent := panels[pan];
Setbounds(5,Add_5.top + Add_5.height + 10,32,13);
Caption := 'Loads Before Switching Players:';
end;
Edit_5 := TEdit.Create(panels[pan]);
with Edit_5 do
begin
Parent := panels[pan];
SetBounds(5,Label_5.top + Label_5.height + 4,150,13);
Caption := '';
end;
Label2_5 := TLabel.Create(panels[pan]);
with Label2_5 do
begin
Parent := panels[pan];
Setbounds(5,Edit_5.top + Edit_5.height + 15,32,13);
Caption := 'Total Loads:';
end;
Edit2_5 := TEdit.Create(panels[pan]);
with Edit2_5 do
begin
Parent := panels[pan];
SetBounds(5,Label2_5.top + Label2_5.height + 4,150,13);
Caption := '';
end;






isLeftTab[IMG_TAB_NORM_1] := true;
panels[IMG_TAB_NORM_1].width := 377;
tImages[11].BringToFront;
senderTab := IMG_TAB_NORM_1;
end;

procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;

procedure ShowFormModal;
begin
frmMain.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;

begin
try
SafeInitForm;
SafeShowFormModal;
finally
time.ENABLED := false;
time.Free;
frmMain.Free;
except
Writeln(ExceptionToString(ExceptionType, ExceptionParam));
end;
end.


EDIT: should I try and make this SCAR compatible? It would really only take a few lines to fix i think, except for simba using .Caption for TEdits, which doesn't really make sense.

Coh3n

2010-09-15 01:31:55

Got deleted? Where…?

I will test this version out tomorrow when I have more time. I'm glad you're still working on this. :) As for making it SCAR compatible, it's up to you, although MSI doesn't work in SCAR right now AFAIK.

I don't know much about SCAR 3.25 Beta (is it?), but if it's been working for scripts, then I'm sure we can cooperate.

Dan Cardin

2010-09-15 07:08:09

afaik, SCAR 3.25 beta is working well and is only missing things that aren't needed in scripting, like some parts of the form editor and such.

The only differences are SafeDrawBitmap (scar) vs DrawBitmap(Simba), TBoolArray, which i can just changed in my version to work either way, and simba using .Caption for TEdits. It would be nice if i could convince the Simba people to change it to .Text because caption doesnt really make sense. And I dont know what I would do for DrawBitmap, since whatever way i do it, it would have to call a function that's not in one or the other.

but i would need to know if people cared if the player you have selected on one panel is the player selected on all panels. It would make it easier to program, but a panel wouldn't keep the same player you were on when you left it, if you changed the player on a different panel.


EDIT: and someone else will need to program the logic for: if such and such an item is checked on the 2nd tab, then show this group of items on tab 3.

Sir R. M8gic1an

2010-09-15 08:45:12


procedure C_DrawBitmap;
begin
{$IFDEF SCAR}
//bla
{$ELSE}
//bla
{$ENDIF}
end;

~RM

Coh3n

2010-09-15 13:26:18

From: Dan Cardin
but i would need to know if people cared if the player you have selected on one panel is the player selected on all panels. It would make it easier to program, but a panel wouldn't keep the same player you were on when you left it, if you changed the player on a different panel.
No, I don't think it matters.

From: Dan Cardin

EDIT: and someone else will need to program the logic for: if such and such an item is checked on the 2nd tab, then show this group of items on tab 3.

I'm not sure what you mean. Aren't all the tabs different? Or are you saying if Woodcutting was checked off, it would display all the trees on the next tab?

Dan Cardin

2010-09-15 17:19:06

From: Sir R. Magician

procedure C_DrawBitmap;
begin
{$IFDEF SCAR}
//bla
{$ELSE}
//bla
{$ENDIF}
end;

~RM


now i dont know much about compiler things such as those, but that would get rid of the problem of calling a procedure that doesn't exist? I thought it would only pick which one to use depending on which one you were using.


Or are you saying if Woodcutting was checked off, it would display all the trees on the next tab?
bingo. That's what the mockups that marpis made looked like. First tab was picking location, 2nd was picking the types of things at that location. I dont know which ones would go with what towards making them show up, and I really dont feel like doing that sort of thing.

EDIT: is it just me or would it make more sense to change all those TImages to integers and make them bitmaps that we draw to a single canvas. It might make some of the stuff a bit more complicated, but it would allow for double buffering when drawing to the screen since, i know some people complained of the screen flickering, which i did encounter on SCAR. I dont know if i'd be willing to make the change right now because i expect it would be a lot of work, but does anyone else think it might be a good idea for future?

Gah…maybe not now that i think of it, because then it would kinda impossible to mix the TEdits with the canvas and such. In that case, is there any way to fix that flickering that anyone can think of? I can't really think of anything off the top of my head.

Coh3n

2010-09-16 00:15:22

From: Dan Cardin
now i dont know much about compiler things such as those, but that would get rid of the problem of calling a procedure that doesn't exist? I thought it would only pick which one to use depending on which one you were using.

They're compiler derivatives and will only compile if the condition is met (i.e. using SCAR). For example, if you were using

procedure MSI_DrawBitmap();
begin
{$IFDEF SIMBA}
DrawBitmap();
{$ELSE}
DrawCanvas(); // Or whatever it is for SCAR
{$ENDIF}
end;
in Simba, DrawCanvas wouldn't be compiled so any errors between {$ELSE}{$ENDIF} wouldn't matter because they wouldn't be compiled. You're right for this situation: that it would choose what procedure to use depending on the IDE you're using.

From: Dan Cardin

bingo. That's what the mockups that marpis made looked like. First tab was picking location, 2nd was picking the types of things at that location. I dont know which ones would go with what towards making them show up, and I really dont feel like doing that sort of thing.

Wouldn't have to. Since it'll be in MSI, we can call the different script attributes to display the name of the object for each script. I would (I think) be something like this:

var
s: string;

s := MSI_Objects[MSI_Players[CurrentPlayer].Objects[CurrentScript][i]].Name;
Where "i" would just be an index in a loop.

From: Dan Cardin

EDIT: is it just me or would it make more sense to change all those TImages to integers and make them bitmaps that we draw to a single canvas. It might make some of the stuff a bit more complicated, but it would allow for double buffering when drawing to the screen since, i know some people complained of the screen flickering, which i did encounter on SCAR. I dont know if i'd be willing to make the change right now because i expect it would be a lot of work, but does anyone else think it might be a good idea for future?

If you're talking about making all the images one image (combining the background/tabs/title/etc.) then we wouldn't be able to show certain other images (highlighted tab, buttons) as easy.

From: Dan Cardin

Gah…maybe not now that i think of it, because then it would kinda impossible to mix the TEdits with the canvas and such. In that case, is there any way to fix that flickering that anyone can think of? I can't really think of anything off the top of my head.

When I was making my form, Nava added a TBooleanArray and called it IsActiveImage so it wouldn't repeatedly draw bitmaps to a canvas if it's already being displayed (if that made any sense), but IIRC ReadySteadyGo formed the base of this form off of my Draynor script one and already has an IsActiveImage boolean array.

However, there may be somewhere where it's not set properly which could very easily cause some flickering (I know because it happened to me multiple times).

Dan Cardin

2010-09-16 17:34:18

-Well Ok, this can be made scar compatible in like…5 minutes. I vote for trying to do the same with MSI.

-Even more reason for me to not do that part. I know nothing of those MSI variables that would make that easier. As it is, i just hard coded those exmaple ones. That will be nice though, because it *should* mean that once you program it to take the info from those, it will update whenever you add new skills and such, and that whole part will never need to update.

Combining the images would completely work though. Right now, you just move the images. If they were combined, it would be like games, where it has all the objects as bitmaps and such and just draws changes. It's still on the same canvas, but there aren't a billion TImages taking up space aswell as it can double buffer and such. The only problem is that not everything is an image. The Panels and all the other stuff isnt, so I would need to work out all the animation logic with non objects which would be a pain, but probably would be possible. I'm only suggesting things though. This would probably take way more work than is worth it for what you're getting out of it.

Coh3n

2010-09-16 17:44:54

From: Dan Cardin
-Well Ok, this can be made scar compatible in like…5 minutes. I vote for trying to do the same with MSI.

I have heard that SCAR Luna is looking nice and some people prefer it over Simba, so it's only reasonable that MSI supports both.

From: Dan Cardin

-Even more reason for me to not do that part. I know nothing of those MSI variables that would make that easier. As it is, i just hard coded those exmaple ones. That will be nice though, because it *should* mean that once you program it to take the info from those, it will update whenever you add new skills and such, and that whole part will never need to update.

That's one of the things I love about MSI - everything's stored in types. Lets us have a lot of features that don't need updating frequently. The Player Remote for example, doesn't need updating at all. It is automatically updated as MSI is.

If you were to get everything working (i.e. loops, components, etc.), I can go through and add the MSI-specific things such as object names. Better yet - if a procedure was written at the top of the script to set global variables (script names, object names, etc.) to be used throughout the form code.

From: Dan Cardin

Combining the images would completely work though. Right now, you just move the images. If they were combined, it would be like games, where it has all the objects as bitmaps and such and just draws changes. It's still on the same canvas, but there aren't a billion TImages taking up space aswell as it can double buffer and such. The only problem is that not everything is an image. The Panels and all the other stuff isnt, so I would need to work out all the animation logic with non objects which would be a pain, but probably would be possible. I'm only suggesting things though. This would probably take way more work than is worth it for what you're getting out of it.

I thought everything was image manipulation? As in when you hover one image, another version (different colors) of the same image is shown. If that isn't the case, could you be more specific as to what parts are strictly images and which aren't?

E: I just committed your updated version. It looks awesome, I really like it. :) The panels (parts that used to be the big gray boxes) are a little too big on some tabs. Sometimes it slightly covers the edges of the tabs. Minor, I know, but I'm picky about stuff like that. :p

There are a few other things that don't really matter right now. I'm more concerned about functionality right now.

Smartzkid

2010-09-16 20:58:31

From: Dan Cardin

Combining the images would completely work though. Right now, you just move the images. If they were combined, it would be like games, where it has all the objects as bitmaps and such and just draws changes. It's still on the same canvas, but there aren't a billion TImages taking up space aswell as it can double buffer and such. The only problem is that not everything is an image. The Panels and all the other stuff isnt, so I would need to work out all the animation logic with non objects which would be a pain, but probably would be possible. I'm only suggesting things though. This would probably take way more work than is worth it for what you're getting out of it.


Were that done, it might make more sense to write your own GUI handler. (Track mouse position & clicks and don't use any built in GUI objects.) Pro: double buffered, very powerful; Con: complex, slower than win32.

Dan Cardin

2010-09-16 21:11:00

The TPanels and TEdits and other form components aren't images, but that isn't as much of a problem in my mind now. But managing hovering over specific parts of the screen and such would be what would need to be changed to change it to all being 1 canvas. Ideally it would just be a bunch of Rectangles that are just the same as the Timages are now, but the nice thing about Timages is that they have OnMouseMove and OnClick Events which would need to be done manually if done otherwise.

are a little too big on some tabs
some? They should all be the same width. That might be a problem if it's some.

If you were to get everything working (i.e. loops, components, etc.), I can go through and add the MSI-specific things such as object names. Better yet - if a procedure was written at the top of the script to set global variables (script names, object names, etc.) to be used throughout the form code.
But i dont know how everything is set up. If you were to just put code that added all the locations from msi during the object creation of the one that i have hard coded right now, that would be it, and easy afaik. I am also trying a bit to make it sound easy becasue i dont want to do it :p. Then the other one might be a bit harder because you'll need to check which of the checkboxes are checked…but the problem is matching up. As long as the order of these things matches up, it should work easily.

What i mean is. 0 = draynor wc, 1 = fally wc, 2 = varrok wc in terms of the array of items on the checkboxlist. Then, as long as the array that holds the values for the trees looks like

[0][0] = tree
[0][1] = willow ////draynor
[0][2] = yew

[1][0] = tree
[1][1] = willow //////fally
[1][2] = yew

[2][0] = tree
[2][1] = willow //////varrok
[2][2] = yew
then it would be easy to match up the numbers from the first one to apply to when you're checking the indexes for being checked and applying the items here. If they're not like that, it will probably get really complicated fast and not be easily updateable.

EDIT:

Con: complex, slower than win32.
if you mean what i think you mean, which would be writing my own text box and such, that would be very complex to say the least. I would rather just pretend like nothing has changed in terms of the GUI objects because iirc, i dont use the positions of the images during the animations, so the only bits reliant on the placements of the images would be the creation, in which i could use the rects i would need of all the images instead of the coordinates of the TImages.

Smartzkid

2010-09-16 21:40:18

I was mostly referring to buttons, tabs, panels, and groupboxes. Textboxes could still be used in their native form.

Coh3n

2010-09-16 22:09:49

From: Dan Cardin
The TPanels and TEdits and other form components aren't images, but that isn't as much of a problem in my mind now. But managing hovering over specific parts of the screen and such would be what would need to be changed to change it to all being 1 canvas. Ideally it would just be a bunch of Rectangles that are just the same as the Timages are now, but the nice thing about Timages is that they have OnMouseMove and OnClick Events which would need to be done manually if done otherwise.

Exactly why leaving them images may be the better route.

From: Dan Cardin

some? They should all be the same width. That might be a problem if it's some.

I was thinking maybe the shifting (animating) is off a pixel or two?

From: Dan Cardin

But i dont know how everything is set up. If you were to just put code that added all the locations from msi during the object creation of the one that i have hard coded right now, that would be it, and easy afaik. I am also trying a bit to make it sound easy becasue i dont want to do it :p. Then the other one might be a bit harder because you'll need to check which of the checkboxes are checked…but the problem is matching up. As long as the order of these things matches up, it should work easily.

I meant it could be written so the check boxes could be changed to ANYTHING by changing only one line.

var
ScriptBoxes: TStringArray;
ObjectBoxes: array of TStringArray;

procedure SetGlobals;
var
i: Integer;
begin
ScriptBoxes := ['Draynor Willows', 'Varrock East Miner', 'Rimmington Gold'];

for i := 0 to High(ScriptBoxes) do
case ScriptBoxes[i] of
'Draynor Willows': ObjectBoxes[i] := ['Willow Tree'];
'Varrock East Miner': ObjectBoxes[i] := ['Iron Ore', 'Tin Ore', 'Copper Ore'];
'Rimmington Gold': ObjectBoxes[i] := ['Gold Ore'];
end;

// Plus whatever else is needed
end;

procedure Init();
var
i: Integer;
begin
SetLength(ScriptCheckBoxes, Length(ScriptBoxes));

for i := 0 to High(ScriptCheckBoxes) do
CheckBoxes[i].Text := ScriptBoxes[i];
end;
That is obviously if we were to hardcode everything, and would be good for testing. Then (like in the above example), the checkboxes would be dependent on the global arrays (would be the same length), so whether or not it's checked will be stored in the CheckBoxes array. They can also be easily called upon because they would match the constants we already have setup.

However, it would eventually look something like this (so it's autoupdated):

procedure SetGlobals;
var
i: Integer;
begin
for i := 0 to High(MSI_Scripts) do
begin
(**
* This part may or may not be needed.
* It's for if the index of the array is empty.
* Using this, the indexes wouldn't match the MSI constants.
*)
if (MSI_Scripts[i].Name = <>) then
Continue;

Inc(j);
SetLength(ScriptBoxes, j);

ScriptBoxes[j - 1] := MSI_Scripts[i].Name;
end;

// Plus the objects and whatever else
end;
I think I kind of already answered the rest of your post.

Dan Cardin

2010-09-17 07:13:40

From: Smartzkid
I was mostly referring to buttons, tabs, panels, and groupboxes. Textboxes could still be used in their native form.


Ah yea, the buttons are supposed to be changed to images once someone has the time to make some images to change them to. panels kinda have to stay where they are though because a tImage cant hold another component on it. So i would need to move all the other components on the tabs manually and separately.

Exactly why leaving them images may be the better route.
It is right now, because the form is too complicated for its own good as it is. There are some parts that I cannot immediately tell how it works (mostly parts i didnt write) and it takes a long time for me to figure it out if at all.

I was thinking maybe the shifting (animating) is off a pixel or two?
yea, i make the Timage animation exact, after it overanimates. I didnt do so for the panels

and indeed to the rest of your post.

Coh3n

2010-09-17 15:51:31

From: Dan Cardin
It is right now, because the form is too complicated for its own good as it is. There are some parts that I cannot immediately tell how it works (mostly parts i didnt write) and it takes a long time for me to figure it out if at all.

Which is why I make such a big deal about standards/organization in my guides.

So the covering of the tabs isn't a hard fix?

Dan Cardin

2010-09-17 22:52:15

It's mostly the loc viewer's fault, along with mouseover's and lastly constants. I think constants make the whole thing harder to deal with. But everyone else likes them…so whatever

program MSIForm;

const
IMG_COUNT = 24;
// Used in frmMain
IMG_BGND = 0;
IMG_X_NORM = 1;
IMG_Q_NORM = 2;
IMG_LOAD_TAB_NORM = 3;
IMG_SAVE_TAB_NORM = 4;
IMG_TAB_NORM_1 = 5;
IMG_TAB_NORM_2 = 6;
IMG_TAB_NORM_3 = 7;
IMG_TAB_NORM_4 = 8;
IMG_TAB_NORM_5 = 9;

// Used in Panel 0 (Is also used for frmMain)
IMG_LOC_ICON_NORM = 10;
IMG_LOC_EXIT_NORM = 11;
IMG_LOC_MAP = 12;
IMG_LOC_NAV = 13;
IMG_LOC_BORD_TOP = 14;
IMG_LOC_BORD_BOTTOM = 15;
IMG_LOC_BORD_LEFT = 16;
IMG_LOC_BORD_RIGHT = 17;
IMG_LOC_BOX_TOP = 18;
IMG_LOC_BOX_LEFT = 19;
IMG_LOC_BOX_RIGHT = 20;
IMG_LOC_BOX_BOTTOM = 21;

IMG_LOC_LABEL = 22;
IMG_TAB_HINT = 23;

PANEL_NUM = 4;
// Used in Panel 1

// Used in Panel 2

// Used in Panel 3

// Used in Panel 4

BITMAP_COUNT = 33;
BGND = 0;
X_NORM = 1;
X_HOVER = 2;
Q_NORM = 3;
Q_HOVER = 4;
LOAD_TAB_NORM = 5;
LOAD_TAB_HOVER = 6;
SAVE_TAB_NORM = 7;
SAVE_TAB_HOVER = 8;
TAB_NORM_1 = 9;
TAB_HOVER_1 = 10;
TAB_NORM_2 = 11;
TAB_HOVER_2 = 12;
TAB_NORM_3 = 13;
TAB_HOVER_3 = 14;
TAB_NORM_4 = 15;
TAB_HOVER_4 = 16;
TAB_NORM_5 = 17;
TAB_HOVER_5 = 18;
LOC_ICON_NORM = 19;
LOC_ICON_HOVER = 20;
LOC_EXIT_NORM = 21;
LOC_EXIT_HOVER = 22;
LOC_MAP = 23;
LOC_NAV = 24;
LOC_BORD_TOP = 25;
LOC_BORD_BOTTOM = 26;
LOC_BORD_LEFT = 27;
LOC_BORD_RIGHT = 28;
LOC_BOX_TOP = 29;
LOC_BOX_LEFT = 30;
LOC_LABEL = 31;
TAB_HINT = 32;

var
frmMain: TForm;
time: TTimer;

tImages: Array[0..IMG_COUNT - 1] of TImage;

frmBitmaps: Array [0..BITMAP_COUNT - 1] of Integer;

isActiveImage: Array[0..IMG_COUNT - 1] of Boolean;
isLeftTab: Array[IMG_TAB_NORM_1..IMG_TAB_NORM_1 + PANEL_NUM - 1] of Boolean;

MapDragStartX, MapDragStartY: Integer;

panels: array [IMG_TAB_NORM_1..IMG_TAB_NORM_1 + PANEL_NUM - 1] of TPanel;





var //Panel 2
UserList: TCheckListBox;
User, Pass: TEdit;
Button1,Button2: TButton;
Label_2, label2_2: TLabel;
var //Panel 3
ComboBox_3: TComboBox;
Add_3, Delete_3: TButton;
CheckListBox_3: TCheckListBox;
var //Panel 4
ComboBox_4: TComboBox;
Add_4, Delete_4: TButton;
CheckListBox_4: TCheckListBox;
var //Panel 5
Label_5, Label2_5: TLabel;
ComboBox_5: TComboBox;
Add_5, Delete_5: TButton;
Edit_5, Edit2_5: TEdit;


procedure OutsideBox(l,t,r,b, obj: integer);
begin
if tImages[obj].Left > l then
tImages[obj].Left := l;
if tImages[obj].Top > t then
tImages[obj].Top := t;
if tImages[obj].Left < r then
tImages[obj].Left := r;
if tImages[obj].Top < b then
tImages[obj].Top := b;
end;

procedure OnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
BoundL, BoundT: Extended;
begin
case sender of
tImages[IMG_LOC_MAP]:
begin
MapDragStartX := x;
MapDragStartY := y;
end;
tImages[IMG_LOC_NAV]:
begin
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x + (x - left), {T} y + (y - top), {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

OutsideBox(0,0,-345, -354, IMG_LOC_MAP);
end;
end;
end;

var
accel, move, senderTab, pan: integer;
cons: array [IMG_TAB_NORM_1..IMG_TAB_NORM_1 + PANEL_NUM - 1] of integer;

procedure TimerTabClick(Sender: TObject);
var
i, e, d, top, bottom: Integer;
begin
d := integer(isLeftTab[senderTab])* 2 - 1;
if isLeftTab[senderTab] then
begin
top := IMG_TAB_NORM_1 + PANEL_NUM - 1
bottom := senderTab + 1;
end else
begin
top := senderTab;
bottom := IMG_TAB_NORM_1
end;

if move = 0 then
for e := bottom to top do
cons[e] := tImages[e].Left;
accel := accel + 2;
move := move + accel;
for i := bottom to top do
if isLeftTab[i] = isLeftTab[senderTab] then
tImages[i].Left := tImages[i].Left + accel * d;

if pan < senderTab then
begin
panels[pan].width := panels[pan].width - accel;
panels[senderTab].left := panels[senderTab].left - accel;
panels[senderTab].width := panels[senderTab].width + accel;
if move >= 377 then
begin
panels[sendertab].left := cons[sendertab] + 377 * d + tImages[sendertab].width;
panels[senderTab].width := 377;
end;
end;
if pan > senderTab then
begin
panels[pan].left := panels[pan].left + accel;
panels[pan].width := panels[pan].width - accel;
panels[senderTab].width := panels[senderTab].width + accel;
if move >= 377 then
begin
panels[pan].width := 0;
panels[sendertab].width := 377;
end;
end;

if move >= 377 then
begin
for e := bottom to top do
if isLeftTab[e] = isLeftTab[senderTab] then
begin
tImages[e].Left := cons[e] + 377 * d;
isLeftTab[e] := not isLeftTab[senderTab];
break;
end;
time.ENABLED := false;
end;
end;

procedure TabClick(Sender: TObject);
var
i: integer;
begin
if not time.ENABLED then
begin
accel := 0;
move := 0;
time.enabled := true;
pan := senderTab;
for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_1 + PANEL_NUM - 1 do
if (Sender = tImages[i]) then
senderTab := i;
end;
end;

procedure LocViewer(Sender: TObject);
var
i: Integer;
am: TintegerArray;
tru: boolean;
begin
am := [IMG_LOC_ICON_NORM, IMG_TAB_HINT, IMG_LOC_LABEL];
case Sender of
tImages[IMG_LOC_ICON_NORM]: begin
tru := true;
for i := low(panels) to high(panels) do
panels[i].visible := false;
end;
tImages[IMG_LOC_EXIT_NORM]: begin
tru := false;
for i := low(panels) to high(panels) do
panels[i].visible := true;
end;
end;

for i := IMG_LOC_EXIT_NORM to IMG_LOC_BOX_BOTTOM do
tImages[i].Visible := tru;

for i := 0 to high(am) do
tImages[am[i]].Visible := not tru;
end;

procedure Clicked(Sender: TObject);
var
i: Integer;
begin
for i := 0 to BITMAP_COUNT - 1 do
FreeBitmap(frmBitmaps[i]);
frmMain.ModalResult := mrOk;
end;

procedure MouseMoved(Sender: TObject; Shift: TShiftState; x, y: Integer);
var
hi, i, bmp, xdif, ydif, h: Integer;
BoundL, BoundT: Extended;
imgSwap, bmpArr, imgArr: Array of Integer;
begin
bmpArr := [ X_NORM, Q_NORM, LOAD_TAB_NORM,
SAVE_TAB_NORM, TAB_NORM_1, TAB_NORM_2,
TAB_NORM_3, TAB_NORM_4, TAB_NORM_5, LOC_ICON_NORM, LOC_EXIT_NORM ]

imgArr := [ IMG_X_NORM, IMG_Q_NORM, IMG_LOAD_TAB_NORM,
IMG_SAVE_TAB_NORM, IMG_TAB_NORM_1, IMG_TAB_NORM_2,
IMG_TAB_NORM_3, IMG_TAB_NORM_4, IMG_TAB_NORM_5, IMG_LOC_ICON_NORM, IMG_LOC_EXIT_NORM ]
hi := High(bmpArr);
case Sender of
tImages[IMG_BGND], tImages[IMG_LOC_MAP]:
begin
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;

bmp := frmBitmaps[bmpArr[i]];
DrawBitmap(bmp,tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;
end;
for h := 0 to hi do
case Sender of
tImages[imgArr[h]]:
begin
imgSwap := [imgArr[h], frmBitmaps[bmpArr[h] + 1]];
if not (isActiveImage[imgSwap[0]]) then
begin
DrawBitmap(imgSwap[1],tImages[imgSwap[0]].Canvas,0,0);
isActiveImage[imgSwap[0]] := True;
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;
if (i = imgSwap[0] - 1) then
Continue;
if imgSwap[0] = IMG_LOC_EXIT_NORM then
if (i = imgSwap[0]) then
Continue;
if imgSwap[0] = IMG_LOC_ICON_NORM then
if (i = imgSwap[0] - 10) then
Continue;
bmp := frmBitmaps[bmpArr[i]];
DrawBitmap(bmp, tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;
end;
end;
case sender of
tImages[IMG_LOC_MAP]:
begin
if not IsMouseButtonDown(1) then exit;
xdif := x - MapDragStartX;
ydif := y - MapDragStartY;
tImages[IMG_LOC_MAP].Left := tImages[IMG_LOC_MAP].Left + xdif;
tImages[IMG_LOC_MAP].Top := tImages[IMG_LOC_MAP].Top + ydif;

OutsideBox(0,0,-854, -765, IMG_LOC_MAP);

BoundL := -tImages[IMG_LOC_MAP].Left / 7.234 + 376;
BoundT := -tImages[IMG_LOC_MAP].Top / 7.234 + 216;


with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} Round(BoundL), {T} Round(BoundT), {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);
end;
tImages[IMG_LOC_NAV]:
begin
if not IsMouseButtonDown(1) then exit;
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x - 55 - 100, {T} y - 40 - 100, {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

OutsideBox(0, 0, -854, -765, IMG_LOC_MAP);
end;
end;
end;

procedure OnClickEvents(Sender: TObject);
var i: integer;
begin
for i := 0 to PANEL_NUM - 1 do
case sender of
tImages[IMG_TAB_NORM_1 + i]: TabClick(Sender);
end;
case Sender of
tImages[IMG_X_NORM]: Clicked(Sender);
tImages[IMG_LOC_ICON_NORM], tImages[IMG_LOC_EXIT_NORM]: LocViewer(Sender);
end;
end;

procedure Panel2Clicks(Sender: TObject);
var sel: integer;
begin
case sender of
Button1: begin
UserList.Items.Append(User.Text + ' (' + Pass.Text + ')');
combobox_3.items.append(User.Text);
combobox_4.items.append(User.Text);
UserList.Checked[UserList.items.Count - 1] := true;
UserList.ItemIndex := UserList.items.Count - 1;
User.Text := '';
Pass.Text := '';
end;
Button2: begin
if UserList.ItemIndex >= 0 then
sel := UserList.ItemIndex;
UserList.Items.Delete(sel);
combobox_3.Items.Delete(sel);
combobox_4.Items.Delete(sel);
if sel = 0 then
sel := 1;
UserList.ItemIndex := sel - 1;
User.Text := '';
Pass.Text := '';
end;
UserList: begin
User.Text := UserList.items.strings[UserList.ItemIndex];
Pass.Text := UserList.items.strings[UserList.ItemIndex];
end;
end;
end;

procedure Panel3Clicks(Sender: TObject);
begin
case sender of
Add_3: begin
if Combobox_3.ITEMINDEX > 0 then
combobox_3.ItemIndex := combobox_3.ItemIndex - 1;
end;
Combobox_3: begin
end;
Delete_3: begin
if Combobox_3.ITEMINDEX < Combobox_3.ITEMS.Count then
combobox_3.ItemIndex := combobox_3.ItemIndex + 1;
end;
end;
end;

procedure Panel4Clicks(Sender: TObject);
begin
case sender of
Add_4: begin
if Combobox_4.ITEMINDEX > 0 then
combobox_4.ItemIndex := combobox_4.ItemIndex - 1;
end;
Combobox_4: begin
end;
Delete_4: begin
if Combobox_4.ITEMINDEX < Combobox_4.ITEMS.Count then
combobox_4.ItemIndex := combobox_4.ItemIndex + 1;
end;
end;
end;

procedure Panel2Clic(Sender: TObject; Index: Integer);
begin

end;

procedure InitForm;
var
i, pan: Integer;
consts: TintegerArray;
bmpArr: TStringArray;
xy: TPointArray;
visibl: array of boolean;
wh: TPoint;
begin
bmpArr := ['BGND','X_NORM','X_HOVER','Q_NORM','Q_HOVER','LOAD_TAB_NORM','LOAD_TAB_HOVER','SAVE_TAB_NORM','SAVE_TAB_HOVER','TAB_NORM_1','TAB_HOVER_1','TAB_NORM_2','TAB_HOVER_2','TAB_NORM_3','TAB_HOVER_3','TAB_NORM_4','TAB_HOVER_4','TAB_NORM_5','TAB_HOVER_5','LOC_ICON_NORM','LOC_ICON_HOVER','LOC_EXIT_NORM','LOC_EXIT_HOVER','LOC_MAP','LOC_NAV','LOC_BORD_TOP','LOC_BORD_BOTTOM','LOC_BORD_LEFT','LOC_BORD_RIGHT','LOC_BOX_TOP','LOC_BOX_LEFT','LOC_LABEL','TAB_HINT'];
for i := 0 to High(frmBitmaps) do
frmBitmaps[i] := LoadBitmap(ScriptPath + 'Bitmaps\' + bmpArr[i] + '.png');

frmMain := TForm.Create(nil);
frmMain.SetBounds({L} 100, {T} 100, {W} 600, {H} 400);
frmMain.Position := poScreenCenter;
frmMain.BorderStyle := bsNone;

time := TTimer.Create(frmMain);
with time do
begin
ONTIMER := @TimerTabClick;
INTERVAL := 10;
ENABLED := false;
end;

xy := [Point(0,0), Point(575,7), Point(557,7), Point(7,69), Point(81,69), Point(9, 100), Point(427,100), Point(468,100), Point(509,100), Point(550,100), Point(30,10), Point(475,7), Point(-300,0), Point(369,209), Point(0,0), Point(0,393), Point(0,7), Point(593,7), Point(Round( 300 / 7.234 + 376), 216), Point(Round( 300 / 7.234 + 376), 216 + 1), Point(Round( 300 / 7.234 + 376) + 83, 216 + 1), Point(Round( 300 / 7.234 + 376), 216 + 1 + 54), Point(7,52), Point(208,379)];
SetArrayLength(visibl, GetArrayLength(xy));
visibl := [true, true, true, true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, true, true];
consts := [BGND, X_NORM, Q_NORM, LOAD_TAB_NORM,SAVE_TAB_NORM,TAB_NORM_1, TAB_NORM_2, TAB_NORM_3, TAB_NORM_4, TAB_NORM_5, LOC_ICON_NORM, LOC_EXIT_NORM, LOC_MAP, LOC_NAV, LOC_BORD_TOP, LOC_BORD_BOTTOM, LOC_BORD_LEFT, LOC_BORD_RIGHT, LOC_BOX_TOP, LOC_BOX_LEFT, LOC_BOX_LEFT, LOC_BOX_TOP, LOC_LABEL, TAB_HINT];

for i := low(panels) to high(panels) do
begin
panels[i] := TPanel.Create(frmMain);
panels[i].parent := frmMain;
GetBitmapSize(frmBitmaps[consts[i]], wh.x, wh.y);
panels[i].SetBounds(xy[i].x + wh.x, xy[i].y, 0, wh.y);
panels[i].BEVELWIDTH := 0;
panels[i].COLOR := 1909544;
end;

for i := 0 to IMG_COUNT - 1 do
begin
tImages[i] := TImage.Create(frmMain)
with tImages[i] do
begin
Parent := frmMain;
GetBitmapSize(frmBitmaps[consts[i]], wh.x, wh.y);
SetBounds(xy[i].x, xy[i].y, wh.x, wh.y);
OnMouseMove := @MouseMoved;
ONMOUSEDOWN := @OnMouseDown;
OnClick := @OnClickEvents;
isActiveImage[i] := False;
visible := Visibl[i];
end;
DrawBitmap(frmBitmaps[consts[i]], tImages[i].canvas, 0, 0);
end;

pan := IMG_TAB_NORM_1;

UserList := TCheckListBox.Create(panels[pan]);
UserList.Parent := panels[pan];
UserList.SetBounds(24,40,225,241);
//UserList.OnItemClick := @Panel2Clic;

Label_2 := TLabel.Create(panels[pan]);
Label_2.Parent := panels[pan];
Label_2.Setbounds(260,50,50,13);
Label_2.Caption := 'Username';

User := TEdit.Create(panels[pan]);
User.Parent := panels[pan];
User.SetBounds(260,Label_2.top + Label_2.height + 4,105,21);

Label2_2 := TLabel.Create(panels[pan]);
Label2_2.Parent := panels[pan];
Label2_2.Setbounds(260,User.top + User.height + 10,32,13);
Label2_2.Caption := 'Password';

Pass := TEdit.Create(panels[pan]);
Pass.Parent := panels[pan];
Pass.SetBounds(260,Label2_2.top + Label2_2.height + 4,105,21);

Button1 := TButton.Create(panels[pan]);
Button1.Parent := panels[pan];
Button1.Setbounds(24,8,107,25);
Button1.Caption := 'Add Player';
Button1.ONCLICK := @Panel2Clicks;

Button2 := TButton.Create(panels[pan]);
Button2.Parent := panels[pan];
Button2.SetBounds(144,8,107,25);
Button2.Caption := 'Remove Player';
Button2.OnClick := @Panel2Clicks;





pan := IMG_TAB_NORM_2;

Add_3 := TButton.Create(panels[pan]);
Add_3.Parent := panels[pan];
Add_3.SetBounds(5,5,73,25);
Add_3.Caption := 'Previous';
Add_3.OnClick := @Panel3Clicks;

ComboBox_3 := TComboBox.Create(panels[pan]);
ComboBox_3.Parent := panels[pan];
ComboBox_3.SetBounds(add_3.left + add_3.width + 5,5,105,21);
ComboBox_3.Text := 'Player';
ComboBox_3.OnClick := @Panel3Clicks;

Delete_3 := TButton.Create(panels[pan]);
Delete_3.Parent := panels[pan];
Delete_3.SetBounds(ComboBox_3.left + ComboBox_3.width + 5,5,75,25);
Delete_3.Caption := 'Next';
Delete_3.OnClick := @Panel3Clicks;

CheckListBox_3 := TCheckListBox.Create(panels[pan]);
CheckListBox_3.Parent := panels[pan];
CheckListBox_3.SetBounds(8,40,365,245);
CheckListBox_3.Items.Append('Woodcutting');
CheckListBox_3.Items.Append('---Varrok East');
CheckListBox_3.Items.Append('---Draynor');
CheckListBox_3.Items.Append('---Port Sarim');
CheckListBox_3.Items.Append('Mining');
CheckListBox_3.Items.Append('---Lumbridge Swamp');
CheckListBox_3.Items.Append('------East');
CheckListBox_3.Items.Append('------West');




pan := IMG_TAB_NORM_3;

Add_4 := TButton.Create(panels[pan]);
Add_4.Parent := panels[pan];
Add_4.SetBounds(5,5,73,25);
Add_4.Caption := 'Previous';
Add_4.OnClick := @Panel4Clicks;

ComboBox_4 := TComboBox.Create(panels[pan]);
ComboBox_4.Parent := panels[pan];
ComboBox_4.SetBounds(add_4.left + add_4.width + 5,5,105,21);
ComboBox_4.Text := 'Player';
ComboBox_4.OnClick := @Panel4Clicks;

Delete_4 := TButton.Create(panels[pan]);
Delete_4.Parent := panels[pan];
Delete_4.SetBounds(ComboBox_4.left + ComboBox_4.width + 5,5,75,25);
Delete_4.Caption := 'Next';
Delete_4.OnClick := @Panel4Clicks;

CheckListBox_4 := TCheckListBox.Create(panels[pan]);
CheckListBox_4.Parent := panels[pan];
CheckListBox_4.SetBounds(8,40,365,245);




pan := IMG_TAB_NORM_4;

Add_5 := TButton.Create(panels[pan]);
Add_5.Parent := panels[pan];
Add_5.SetBounds(5,5,73,25);
Add_5.Caption := 'Previous';

ComboBox_5 := TComboBox.Create(panels[pan]);
ComboBox_5.Parent := panels[pan];
ComboBox_5.SetBounds(add_5.left + add_5.width + 5,5,105,21);
ComboBox_5.Text := 'Player';

Delete_5 := TButton.Create(panels[pan]);
Delete_5.Parent := panels[pan];
Delete_5.SetBounds(ComboBox_5.left + ComboBox_5.width + 5,5,75,25);
Delete_5.Caption := 'Next';

Label_5 := TLabel.Create(panels[pan]);
with Label_5 do
begin
Parent := panels[pan];
Setbounds(5,Add_5.top + Add_5.height + 10,32,13);
Caption := 'Loads Before Switching Players:';
end;
Edit_5 := TEdit.Create(panels[pan]);
with Edit_5 do
begin
Parent := panels[pan];
SetBounds(5,Label_5.top + Label_5.height + 4,150,13);
Caption := '';
end;
Label2_5 := TLabel.Create(panels[pan]);
with Label2_5 do
begin
Parent := panels[pan];
Setbounds(5,Edit_5.top + Edit_5.height + 15,32,13);
Caption := 'Total Loads:';
end;
Edit2_5 := TEdit.Create(panels[pan]);
with Edit2_5 do
begin
Parent := panels[pan];
SetBounds(5,Label2_5.top + Label2_5.height + 4,150,13);
Caption := '';
end;






isLeftTab[IMG_TAB_NORM_1] := true;
panels[IMG_TAB_NORM_1].width := 377;
tImages[11].BringToFront;
senderTab := IMG_TAB_NORM_1;
end;

procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;

procedure ShowFormModal;
begin
frmMain.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;

begin
try
SafeInitForm;
SafeShowFormModal;
finally
time.ENABLED := false;
time.Free;
frmMain.Free;
except
Writeln(ExceptionToString(ExceptionType, ExceptionParam));
end;
end.
I thought moving the panels moving above the images updating would fix the kind of ghost image the panels leave when animating…but it didnt. :(

Dan Cardin

2010-09-18 18:42:01

program MSIForm;

const
IMG_COUNT = 24;
// Used in frmMain
IMG_BGND = 0;
IMG_X_NORM = 1;
IMG_Q_NORM = 2;
IMG_LOAD_TAB_NORM = 3;
IMG_SAVE_TAB_NORM = 4;
IMG_TAB_NORM_1 = 5;
IMG_TAB_NORM_2 = 6;
IMG_TAB_NORM_3 = 7;
IMG_TAB_NORM_4 = 8;
IMG_TAB_NORM_5 = 9;

// Used in Panel 0 (Is also used for frmMain)
IMG_LOC_ICON_NORM = 10;
IMG_LOC_EXIT_NORM = 11;
IMG_LOC_MAP = 12;
IMG_LOC_NAV = 13;
IMG_LOC_BORD_TOP = 14;
IMG_LOC_BORD_BOTTOM = 15;
IMG_LOC_BORD_LEFT = 16;
IMG_LOC_BORD_RIGHT = 17;
IMG_LOC_BOX_TOP = 18;
IMG_LOC_BOX_LEFT = 19;
IMG_LOC_BOX_RIGHT = 20;
IMG_LOC_BOX_BOTTOM = 21;

IMG_LOC_LABEL = 22;
IMG_TAB_HINT = 23;

PANEL_NUM = 4;
// Used in Panel 1

// Used in Panel 2

// Used in Panel 3

// Used in Panel 4

BITMAP_COUNT = 33;
BGND = 0;
X_NORM = 1;
X_HOVER = 2;
Q_NORM = 3;
Q_HOVER = 4;
LOAD_TAB_NORM = 5;
LOAD_TAB_HOVER = 6;
SAVE_TAB_NORM = 7;
SAVE_TAB_HOVER = 8;
TAB_NORM_1 = 9;
TAB_HOVER_1 = 10;
TAB_NORM_2 = 11;
TAB_HOVER_2 = 12;
TAB_NORM_3 = 13;
TAB_HOVER_3 = 14;
TAB_NORM_4 = 15;
TAB_HOVER_4 = 16;
TAB_NORM_5 = 17;
TAB_HOVER_5 = 18;
LOC_ICON_NORM = 19;
LOC_ICON_HOVER = 20;
LOC_EXIT_NORM = 21;
LOC_EXIT_HOVER = 22;
LOC_MAP = 23;
LOC_NAV = 24;
LOC_BORD_TOP = 25;
LOC_BORD_BOTTOM = 26;
LOC_BORD_LEFT = 27;
LOC_BORD_RIGHT = 28;
LOC_BOX_TOP = 29;
LOC_BOX_LEFT = 30;
LOC_LABEL = 31;
TAB_HINT = 32;

var
frmMain: TForm;
time: TTimer;

tImages: Array[0..IMG_COUNT - 1] of TImage;

frmBitmaps: Array [0..BITMAP_COUNT - 1] of Integer;

isActiveImage: Array[0..IMG_COUNT - 1] of Boolean;
isLeftTab: Array[IMG_TAB_NORM_1..IMG_TAB_NORM_1 + PANEL_NUM - 1] of Boolean;

MapDragStartX, MapDragStartY: Integer;

panels: array [IMG_TAB_NORM_1..IMG_TAB_NORM_1 + PANEL_NUM - 1] of TPanel;





var //Panel 2
UserList: TCheckListBox;
User, Pass: TEdit;
Button1,Button2: TButton;
Label_2, label2_2: TLabel;
var //Panel 3
ComboBox_3: TComboBox;
Add_3, Delete_3: TButton;
CheckListBox_3: TCheckListBox;
var //Panel 4
ComboBox_4: TComboBox;
Add_4, Delete_4: TButton;
CheckListBox_4: TCheckListBox;
var //Panel 5
Label_5, Label2_5: TLabel;
ComboBox_5: TComboBox;
Add_5, Delete_5: TButton;
Edit_5, Edit2_5: TEdit;


procedure OutsideBox(l,t,r,b, obj: integer);
begin
if tImages[obj].Left > l then
tImages[obj].Left := l;
if tImages[obj].Top > t then
tImages[obj].Top := t;
if tImages[obj].Left < r then
tImages[obj].Left := r;
if tImages[obj].Top < b then
tImages[obj].Top := b;
end;

procedure DDrawBitmap(Bmp: Longint; dest: TCanvas; x,y: integer);
begin
{$IFDEF SIMBA}
DrawBitmap(Bmp,dest,x,y);
{$ELSE}
SafeDrawBitmap(Bmp,dest,x,y);
{$ENDIF}
end;

function IsMouseButtonDow(yes: LongInt): boolean;
begin
{$IFDEF SIMBA}
result := IsMouseButtonDown(yes);
{$ELSE}
if yes = 1 then
result := IsMouseButtonDown(True)
else
result := IsMouseButtonDown(False);
{$ENDIF}
end;

procedure OnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
BoundL, BoundT: Extended;
begin
case sender of
tImages[IMG_LOC_MAP]:
begin
MapDragStartX := x;
MapDragStartY := y;
end;
tImages[IMG_LOC_NAV]:
begin
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x + (x - left), {T} y + (y - top), {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

OutsideBox(0,0,-345, -354, IMG_LOC_MAP);
end;
end;
end;

var
accel, move, senderTab, pan: integer;
cons: array [IMG_TAB_NORM_1..IMG_TAB_NORM_1 + PANEL_NUM - 1] of integer;

procedure TimerTabClick(Sender: TObject);
var
i, e, d, top, bottom: Integer;
begin
d := integer(isLeftTab[senderTab])* 2 - 1;
if isLeftTab[senderTab] then
begin
top := IMG_TAB_NORM_1 + PANEL_NUM - 1
bottom := senderTab + 1;
end else
begin
top := senderTab;
bottom := IMG_TAB_NORM_1
end;

if move = 0 then
for e := bottom to top do
cons[e] := tImages[e].Left;
accel := accel + 2;
move := move + accel;
for i := bottom to top do
if isLeftTab[i] = isLeftTab[senderTab] then
tImages[i].Left := tImages[i].Left + accel * d;

if pan < senderTab then
begin
panels[pan].width := panels[pan].width - accel;
panels[senderTab].left := panels[senderTab].left - accel;
panels[senderTab].width := panels[senderTab].width + accel;
if move >= 377 then
begin
panels[sendertab].left := cons[sendertab] + 377 * d + tImages[sendertab].width;
panels[senderTab].width := 377;
end;
end;
if pan > senderTab then
begin
panels[pan].left := panels[pan].left + accel;
panels[pan].width := panels[pan].width - accel;
panels[senderTab].width := panels[senderTab].width + accel;
if move >= 377 then
begin
panels[pan].width := 0;
panels[sendertab].width := 377;
end;
end;

if move >= 377 then
begin
for e := bottom to top do
if isLeftTab[e] = isLeftTab[senderTab] then
begin
tImages[e].Left := cons[e] + 377 * d;
isLeftTab[e] := not isLeftTab[senderTab];
break;
end;
time.ENABLED := false;
end;
end;

procedure TabClick(Sender: TObject);
var
i: integer;
begin
if not time.ENABLED then
begin
accel := 0;
move := 0;
time.enabled := true;
pan := senderTab;
for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_1 + PANEL_NUM - 1 do
if (Sender = tImages[i]) then
senderTab := i;
end;
end;

procedure LocViewer(Sender: TObject);
var
i: Integer;
am: TintegerArray;
tru: boolean;
begin
am := [IMG_LOC_ICON_NORM, IMG_TAB_HINT, IMG_LOC_LABEL];
case Sender of
tImages[IMG_LOC_ICON_NORM]: begin
tru := true;
for i := low(panels) to high(panels) do
panels[i].visible := false;
end;
tImages[IMG_LOC_EXIT_NORM]: begin
tru := false;
for i := low(panels) to high(panels) do
panels[i].visible := true;
end;
end;

for i := IMG_LOC_EXIT_NORM to IMG_LOC_BOX_BOTTOM do
tImages[i].Visible := tru;

for i := 0 to high(am) do
tImages[am[i]].Visible := not tru;
end;

procedure Clicked(Sender: TObject);
var
i: Integer;
begin
for i := 0 to BITMAP_COUNT - 1 do
FreeBitmap(frmBitmaps[i]);
frmMain.ModalResult := mrOk;
end;

procedure MouseMoved(Sender: TObject; Shift: TShiftState; x, y: Integer);
var
hi, i, bmp, xdif, ydif, h: Integer;
BoundL, BoundT: Extended;
imgSwap, bmpArr, imgArr: Array of Integer;
begin
bmpArr := [ X_NORM, Q_NORM, LOAD_TAB_NORM,
SAVE_TAB_NORM, TAB_NORM_1, TAB_NORM_2,
TAB_NORM_3, TAB_NORM_4, TAB_NORM_5, LOC_ICON_NORM, LOC_EXIT_NORM ]

imgArr := [ IMG_X_NORM, IMG_Q_NORM, IMG_LOAD_TAB_NORM,
IMG_SAVE_TAB_NORM, IMG_TAB_NORM_1, IMG_TAB_NORM_2,
IMG_TAB_NORM_3, IMG_TAB_NORM_4, IMG_TAB_NORM_5, IMG_LOC_ICON_NORM, IMG_LOC_EXIT_NORM ]
hi := High(bmpArr);
case Sender of
tImages[IMG_BGND], tImages[IMG_LOC_MAP]:
begin
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;

bmp := frmBitmaps[bmpArr[i]];
DDrawBitmap(bmp,tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;
end;
for h := 0 to hi do
case Sender of
tImages[imgArr[h]]:
begin
imgSwap := [imgArr[h], frmBitmaps[bmpArr[h] + 1]];
if not (isActiveImage[imgSwap[0]]) then
begin
DDrawBitmap(imgSwap[1],tImages[imgSwap[0]].Canvas,0,0);
isActiveImage[imgSwap[0]] := True;
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;
if (i = imgSwap[0] - 1) then
Continue;
if imgSwap[0] = IMG_LOC_EXIT_NORM then
if (i = imgSwap[0]) then
Continue;
if imgSwap[0] = IMG_LOC_ICON_NORM then
if (i = imgSwap[0] - 10) then
Continue;
bmp := frmBitmaps[bmpArr[i]];
DDrawBitmap(bmp, tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;
end;
end;
case sender of
tImages[IMG_LOC_MAP]:
begin
if not IsMouseButtonDow(1) then exit;
xdif := x - MapDragStartX;
ydif := y - MapDragStartY;
tImages[IMG_LOC_MAP].Left := tImages[IMG_LOC_MAP].Left + xdif;
tImages[IMG_LOC_MAP].Top := tImages[IMG_LOC_MAP].Top + ydif;

OutsideBox(0,0,-854, -765, IMG_LOC_MAP);

BoundL := -tImages[IMG_LOC_MAP].Left / 7.234 + 376;
BoundT := -tImages[IMG_LOC_MAP].Top / 7.234 + 216;


with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} Round(BoundL), {T} Round(BoundT), {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);
end;
tImages[IMG_LOC_NAV]:
begin
if not IsMouseButtonDow(1) then exit;
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x - 55 - 100, {T} y - 40 - 100, {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

OutsideBox(0, 0, -854, -765, IMG_LOC_MAP);
end;
end;
end;

procedure OnClickEvents(Sender: TObject);
var i: integer;
begin
for i := 0 to PANEL_NUM - 1 do
case sender of
tImages[IMG_TAB_NORM_1 + i]: TabClick(Sender);
end;
case Sender of
tImages[IMG_X_NORM]: Clicked(Sender);
tImages[IMG_LOC_ICON_NORM], tImages[IMG_LOC_EXIT_NORM]: LocViewer(Sender);
end;
end;

procedure Panel2Clicks(Sender: TObject);
var sel: integer;
begin
case sender of
Button1: begin
UserList.Items.Append(User.Text + ' (' + Pass.Text + ')');
combobox_3.items.append(User.Text);
combobox_4.items.append(User.Text);
UserList.Checked[UserList.items.Count - 1] := true;
UserList.ItemIndex := UserList.items.Count - 1;
User.Text := '';
Pass.Text := '';
end;
Button2: begin
if UserList.ItemIndex >= 0 then
sel := UserList.ItemIndex;
UserList.Items.Delete(sel);
combobox_3.Items.Delete(sel);
combobox_4.Items.Delete(sel);
if sel = 0 then
sel := 1;
UserList.ItemIndex := sel - 1;
User.Text := '';
Pass.Text := '';
end;
UserList: begin
User.Text := UserList.items.strings[UserList.ItemIndex];
Pass.Text := UserList.items.strings[UserList.ItemIndex];
end;
end;
end;

procedure Panel3Clicks(Sender: TObject);
begin
case sender of
Add_3: begin
if Combobox_3.ITEMINDEX > 0 then
combobox_3.ItemIndex := combobox_3.ItemIndex - 1;
end;
Combobox_3: begin
end;
Delete_3: begin
if Combobox_3.ITEMINDEX < Combobox_3.ITEMS.Count then
combobox_3.ItemIndex := combobox_3.ItemIndex + 1;
end;
end;
end;

procedure Panel4Clicks(Sender: TObject);
begin
case sender of
Add_4: begin
if Combobox_4.ITEMINDEX > 0 then
combobox_4.ItemIndex := combobox_4.ItemIndex - 1;
end;
Combobox_4: begin
end;
Delete_4: begin
if Combobox_4.ITEMINDEX < Combobox_4.ITEMS.Count then
combobox_4.ItemIndex := combobox_4.ItemIndex + 1;
end;
end;
end;

procedure Panel2Clic(Sender: TObject; Index: Integer);
begin

end;

procedure InitForm;
var
i, pan: Integer;
consts: TintegerArray;
bmpArr: TStringArray;
xy: TPointArray;
visibl: array of boolean;
wh: TPoint;
begin
bmpArr := ['BGND','X_NORM','X_HOVER','Q_NORM','Q_HOVER','LOAD_TAB_NORM','LOAD_TAB_HOVER','SAVE_TAB_NORM','SAVE_TAB_HOVER','TAB_NORM_1','TAB_HOVER_1','TAB_NORM_2','TAB_HOVER_2','TAB_NORM_3','TAB_HOVER_3','TAB_NORM_4','TAB_HOVER_4','TAB_NORM_5','TAB_HOVER_5','LOC_ICON_NORM','LOC_ICON_HOVER','LOC_EXIT_NORM','LOC_EXIT_HOVER','LOC_MAP','LOC_NAV','LOC_BORD_TOP','LOC_BORD_BOTTOM','LOC_BORD_LEFT','LOC_BORD_RIGHT','LOC_BOX_TOP','LOC_BOX_LEFT','LOC_LABEL','TAB_HINT'];
for i := 0 to High(frmBitmaps) do
frmBitmaps[i] := LoadBitmap(ScriptPath + 'Bitmaps\' + bmpArr[i] + '.png');

frmMain := TForm.Create(nil);
frmMain.SetBounds({L} 100, {T} 100, {W} 600, {H} 400);
frmMain.Position := poScreenCenter;
frmMain.BorderStyle := bsNone;

time := TTimer.Create(frmMain);
with time do
begin
ONTIMER := @TimerTabClick;
INTERVAL := 10;
ENABLED := false;
end;

xy := [Point(0,0), Point(575,7), Point(557,7), Point(7,69), Point(81,69), Point(9, 100), Point(427,100), Point(468,100), Point(509,100), Point(550,100), Point(30,10), Point(475,7), Point(-300,0), Point(369,209), Point(0,0), Point(0,393), Point(0,7), Point(593,7), Point(Round( 300 / 7.234 + 376), 216), Point(Round( 300 / 7.234 + 376), 216 + 1), Point(Round( 300 / 7.234 + 376) + 83, 216 + 1), Point(Round( 300 / 7.234 + 376), 216 + 1 + 54), Point(7,52), Point(208,379)];
SetArrayLength(visibl, GetArrayLength(xy));
visibl := [true, true, true, true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, true, true];
consts := [BGND, X_NORM, Q_NORM, LOAD_TAB_NORM,SAVE_TAB_NORM,TAB_NORM_1, TAB_NORM_2, TAB_NORM_3, TAB_NORM_4, TAB_NORM_5, LOC_ICON_NORM, LOC_EXIT_NORM, LOC_MAP, LOC_NAV, LOC_BORD_TOP, LOC_BORD_BOTTOM, LOC_BORD_LEFT, LOC_BORD_RIGHT, LOC_BOX_TOP, LOC_BOX_LEFT, LOC_BOX_LEFT, LOC_BOX_TOP, LOC_LABEL, TAB_HINT];

for i := low(panels) to high(panels) do
begin
panels[i] := TPanel.Create(frmMain);
panels[i].parent := frmMain;
GetBitmapSize(frmBitmaps[consts[i]], wh.x, wh.y);
panels[i].SetBounds(xy[i].x + wh.x, xy[i].y, 0, wh.y);
panels[i].BEVELWIDTH := 0;
panels[i].COLOR := 1909544;
end;

for i := 0 to IMG_COUNT - 1 do
begin
tImages[i] := TImage.Create(frmMain)
with tImages[i] do
begin
Parent := frmMain;
GetBitmapSize(frmBitmaps[consts[i]], wh.x, wh.y);
SetBounds(xy[i].x, xy[i].y, wh.x, wh.y);
OnMouseMove := @MouseMoved;
ONMOUSEDOWN := @OnMouseDown;
OnClick := @OnClickEvents;
isActiveImage[i] := False;
visible := Visibl[i];
end;
DDrawBitmap(frmBitmaps[consts[i]], tImages[i].canvas, 0, 0);
end;

pan := IMG_TAB_NORM_1;

UserList := TCheckListBox.Create(panels[pan]);
UserList.Parent := panels[pan];
UserList.SetBounds(24,40,225,241);
//UserList.OnItemClick := @Panel2Clic;

Label_2 := TLabel.Create(panels[pan]);
Label_2.Parent := panels[pan];
Label_2.Setbounds(260,50,50,13);
Label_2.Caption := 'Username';

User := TEdit.Create(panels[pan]);
User.Parent := panels[pan];
User.SetBounds(260,Label_2.top + Label_2.height + 4,105,21);

Label2_2 := TLabel.Create(panels[pan]);
Label2_2.Parent := panels[pan];
Label2_2.Setbounds(260,User.top + User.height + 10,32,13);
Label2_2.Caption := 'Password';

Pass := TEdit.Create(panels[pan]);
Pass.Parent := panels[pan];
Pass.SetBounds(260,Label2_2.top + Label2_2.height + 4,105,21);

Button1 := TButton.Create(panels[pan]);
Button1.Parent := panels[pan];
Button1.Setbounds(24,8,107,25);
Button1.Caption := 'Add Player';
Button1.ONCLICK := @Panel2Clicks;

Button2 := TButton.Create(panels[pan]);
Button2.Parent := panels[pan];
Button2.SetBounds(144,8,107,25);
Button2.Caption := 'Remove Player';
Button2.OnClick := @Panel2Clicks;





pan := IMG_TAB_NORM_2;

Add_3 := TButton.Create(panels[pan]);
Add_3.Parent := panels[pan];
Add_3.SetBounds(5,5,73,25);
Add_3.Caption := 'Previous';
Add_3.OnClick := @Panel3Clicks;

ComboBox_3 := TComboBox.Create(panels[pan]);
ComboBox_3.Parent := panels[pan];
ComboBox_3.SetBounds(add_3.left + add_3.width + 5,5,105,21);
ComboBox_3.Text := 'Player';
ComboBox_3.OnClick := @Panel3Clicks;

Delete_3 := TButton.Create(panels[pan]);
Delete_3.Parent := panels[pan];
Delete_3.SetBounds(ComboBox_3.left + ComboBox_3.width + 5,5,75,25);
Delete_3.Caption := 'Next';
Delete_3.OnClick := @Panel3Clicks;

CheckListBox_3 := TCheckListBox.Create(panels[pan]);
CheckListBox_3.Parent := panels[pan];
CheckListBox_3.SetBounds(8,40,365,245);
CheckListBox_3.Items.Append('Woodcutting');
CheckListBox_3.Items.Append('---Varrok East');
CheckListBox_3.Items.Append('---Draynor');
CheckListBox_3.Items.Append('---Port Sarim');
CheckListBox_3.Items.Append('Mining');
CheckListBox_3.Items.Append('---Lumbridge Swamp');
CheckListBox_3.Items.Append('------East');
CheckListBox_3.Items.Append('------West');




pan := IMG_TAB_NORM_3;

Add_4 := TButton.Create(panels[pan]);
Add_4.Parent := panels[pan];
Add_4.SetBounds(5,5,73,25);
Add_4.Caption := 'Previous';
Add_4.OnClick := @Panel4Clicks;

ComboBox_4 := TComboBox.Create(panels[pan]);
ComboBox_4.Parent := panels[pan];
ComboBox_4.SetBounds(add_4.left + add_4.width + 5,5,105,21);
ComboBox_4.Text := 'Player';
ComboBox_4.OnClick := @Panel4Clicks;

Delete_4 := TButton.Create(panels[pan]);
Delete_4.Parent := panels[pan];
Delete_4.SetBounds(ComboBox_4.left + ComboBox_4.width + 5,5,75,25);
Delete_4.Caption := 'Next';
Delete_4.OnClick := @Panel4Clicks;

CheckListBox_4 := TCheckListBox.Create(panels[pan]);
CheckListBox_4.Parent := panels[pan];
CheckListBox_4.SetBounds(8,40,365,245);




pan := IMG_TAB_NORM_4;

Add_5 := TButton.Create(panels[pan]);
Add_5.Parent := panels[pan];
Add_5.SetBounds(5,5,73,25);
Add_5.Caption := 'Previous';

ComboBox_5 := TComboBox.Create(panels[pan]);
ComboBox_5.Parent := panels[pan];
ComboBox_5.SetBounds(add_5.left + add_5.width + 5,5,105,21);
ComboBox_5.Text := 'Player';

Delete_5 := TButton.Create(panels[pan]);
Delete_5.Parent := panels[pan];
Delete_5.SetBounds(ComboBox_5.left + ComboBox_5.width + 5,5,75,25);
Delete_5.Caption := 'Next';

Label_5 := TLabel.Create(panels[pan]);
with Label_5 do
begin
Parent := panels[pan];
Setbounds(5,Add_5.top + Add_5.height + 10,32,13);
Caption := 'Loads Before Switching Players:';
end;
Edit_5 := TEdit.Create(panels[pan]);
with Edit_5 do
begin
Parent := panels[pan];
SetBounds(5,Label_5.top + Label_5.height + 4,150,13);
end;
Label2_5 := TLabel.Create(panels[pan]);
with Label2_5 do
begin
Parent := panels[pan];
Setbounds(5,Edit_5.top + Edit_5.height + 15,32,13);
Caption := 'Total Loads:';
end;
Edit2_5 := TEdit.Create(panels[pan]);
with Edit2_5 do
begin
Parent := panels[pan];
SetBounds(5,Label2_5.top + Label2_5.height + 4,150,13);
end;






isLeftTab[IMG_TAB_NORM_1] := true;
panels[IMG_TAB_NORM_1].width := 377;
tImages[11].BringToFront;
senderTab := IMG_TAB_NORM_1;
end;

procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;

procedure ShowFormModal;
begin
frmMain.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;

begin
try
SafeInitForm;
SafeShowFormModal;
finally
time.ENABLED := false;
time.Free;
frmMain.Free;
except
Writeln(ExceptionToString(ExceptionType, ExceptionParam));
end;
end.
works with SCAR and Simba

marpis

2010-09-20 00:45:27

Looks great Dan! :)
You probably know these but I'm still going to suggest:
  • When clicking Remove player, make it delete players that are chosen
  • The tabs go crazy when clicking them in different order
  • Make it work wheter or not "Woodcutting" is chosen, the main thing is that the location is chosen.

Dan Cardin

2010-09-20 07:11:47

1: it doesn't do that?
2: yea, yea
3: what? I havent done anything with that stuff iirc.

What would be nice is if Simba had a tree style checkbox list thing. It would look nicer and make it easier to program because one can check and uncheck things by group.

Coh3n

2010-09-20 15:56:15

From: Dan Cardin

What would be nice is if Simba had a tree style checkbox list thing. It would look nicer and make it easier to program because one can check and uncheck things by group.

Does SCAR?

Also, committed your updated version.

Dan Cardin

2010-09-20 21:19:28

Scar seems to have a TTreeView and a TListView. I dont know if we could do something with the TTreeview to have each item have a checkbox, which might be possible. I am not quite sure what exactly a TListView is, but it has a checkbox property, and it looks like it works similar to a TTree. And it looks like it can do groups, but which would be helpful. I'd have to test things with it though to see.

Coh3n

2010-09-20 22:42:56

From: Dan Cardin
Scar seems to have a TTreeView and a TListView. I dont know if we could do something with the TTreeview to have each item have a checkbox, which might be possible. I am not quite sure what exactly a TListView is, but it has a checkbox property, and it looks like it works similar to a TTree. And it looks like it can do groups, but which would be helpful. I'd have to test things with it though to see.

Well both SCAR and Simba use Pascal Script so shouldn't they have the same types like that, or is that completely irrelevant?

marpis

2010-09-21 00:35:58

From: Dan Cardin
1: it doesn't do that?

It deleted just the last player in the list

From: Dan Cardin

3: what? I havent done anything with that stuff iirc.

No, you haven't, just suggested you to do that when you get to those things :)

From: Dan Cardin

What would be nice is if Simba had a tree style checkbox list thing. It would look nicer and make it easier to program because one can check and uncheck things by group.

Could you possibly disable checkboxes of the headers, like "Woodcutting" and "Mining"? That would make it look nicer too. Dunno if it's simple though.

Dan Cardin

2010-09-21 07:01:15

From: Coh3n
Well both SCAR and Simba use Pascal Script so shouldn't they have the same types like that, or is that completely irrelevant?
it all depends on what they have implemented.

From: marpis
It deleted just the last player in the list
i dont remember posting a version that didnt work but i cant get the current version to do that, personally.

From: marpis
Could you possibly disable checkboxes of the headers, like "Woodcutting" and "Mining"? That would make it look nicer too. Dunno if it's simple though.
Not to my knowledge, and if there was, then it would only be in appearance (though i dont think there's a way to do that in Simba). The checkbox would still be there as a property, so it wouldnt help coding either.

Coh3n

2010-10-16 16:52:55

Okay guys, I think I figured out the tab thing. I couldn't find it so I just rewrote the looping to make the tabs just move to the other side (no acceleration). They all work perfectly, so now the acceleration just needs to be added to the looping. I wrote the looping in TabClick.

I changed it so all 5 tabs start on the right side and the initial page can be like the "home" tab if you will. The issue right now is that if the first tab is on the left and you click it, it will move to the right and open the home tab rather than stay on the left and show the first tab.

I was thinking we could move the left tabs over 20 or something and add like a small "<<" button in that extra space on the left, that way is acts as another tab, but isn't actually a tab. Hopefully you know what I mean. :p

If you run the new form, don't panic, I didn't delete anything, I just made a few things invisible for testing and such. Also, does anyone happen to have the .png of all the images in the bitmap folder? I would like to make the tabs "glow" when they're active. It may look shitty, but you never know. :p

The whole form can be downloaded from the link in the first post. I plan on working on this along side the changes to DeclarePlayers. Hopefully it won't take me months to finish.

Dan Cardin

2010-10-17 10:12:42

whats the link (not in the first post afai can tell)? Cuz it totally out of ranges for me when clicking stuff, so i assume it's not the correct one, so i have the wrong link. I was fairly sure that the animation was the part that was screwing it up before anyway. So i assume if i try to copy and paste that in, it will be the same. Though mayhaps not.

Coh3n

2010-10-17 14:40:57

From: Dan Cardin
whats the link (not in the first post afai can tell)? Cuz it totally out of ranges for me when clicking stuff, so i assume it's not the correct one, so i have the wrong link. I was fairly sure that the animation was the part that was screwing it up before anyway. So i assume if i try to copy and paste that in, it will be the same. Though mayhaps not.

https://msiplayerform.googlecode.com/svn/trunk/

I just tested and that one works for me. It's in a quote on the first post, but it's not a hyperlink for some reason. Also, just copying/pasting probably won't work, you're right. I hope to take a better look at it soon and see if I can figure it out. In the meantime, if you think you can, awesome. A tip though, don't worry about the panel shifting and such, just start small. Get the tabs working, then build from there.

Dan Cardin

2010-10-17 19:19:32

I'm not sure that I would do such a great job doing the animation again. The way I did it is probably how i would do it now. I dont even know. I feel like the way i dealt with islefttab is what the problem is. Like i didnt set it to the correct value always, i think. Idnno.

Coh3n

2010-10-17 19:22:31

From: Dan Cardin
I'm not sure that I would do such a great job doing the animation again. The way I did it is probably how i would do it now. I dont even know. I feel like the way i dealt with islefttab is what the problem is. Like i didnt set it to the correct value always, i think. Idnno.

Well when I rewrote the looping, it was all based off what was already there, so I will probably do the same with the animating. I'm leaving for a week road trip tomorrow, so I'll have a lot of time on the bus to work with the form (hopefully). I should be able to make some progress.

Dan Cardin

2010-10-18 19:42:09

It just looked different and its not in the timer. So it would be a process to get it back into that again.

Coh3n

2010-10-19 01:29:39

From: Dan Cardin
It just looked different and its not in the timer. So it would be a process to get it back into that again.

Yeah I wasn't too sure about that either. I'm gonna have to read up on TTimers. What was the reason using one in the first place? Can the same effect not be done without it?

Dan Cardin

2010-10-19 14:01:08

You can't draw in a for loop and expect it to actually draw the anything but what's on the bitmap at the end of the loop. So you need to basically have to use a timer. There's not much to them. It calls the procedure every however many seconds. So basically when something is clicked, call the first proc which needs to enable the timer and reset variables if needed, then when you figure out that you're done in the timer, you disable it. Done. it just gets kind of annoying having to set global variables so that your timer proc can know where it's at. Especially making it short.

I think i did a good job at making it short, but again, there's that bug. Now i do think, though, that its an islefttab problem because im fairly sure it shows them all as being true all the time.

Coh3n

2010-10-19 14:48:50

From: Dan Cardin
You can't draw in a for loop and expect it to actually draw the anything but what's on the bitmap at the end of the loop. So you need to basically have to use a timer. There's not much to them. It calls the procedure every however many seconds. So basically when something is clicked, call the first proc which needs to enable the timer and reset variables if needed, then when you figure out that you're done in the timer, you disable it. Done. it just gets kind of annoying having to set global variables so that your timer proc can know where it's at. Especially making it short.

Oh okay, I was still unsure as to why so many global vars were being used, but that makes it clear now.

From: Dan Cardin

I think i did a good job at making it short, but again, there's that bug. Now i do think, though, that its an islefttab problem because im fairly sure it shows them all as being true all the time.

Yeah I had a lot of trouble with IsLeftTab. Took me a while to get it right, so that could be it.

Dan Cardin

2010-10-19 17:40:57

I dont get why we dont just have a variable saying which one is selected, then if <= selected its lefttab. Easier and no need to manage it.

Coh3n

2010-10-19 19:01:19

From: Dan Cardin
I dont get why we dont just have a variable saying which one is selected, then if <= selected its lefttab. Easier and no need to manage it.

I suppose that would work too. I can't think of a reason for it not to anyway. I just went with what was already there. Now that it works (or almost works), I don't want to change it now. :p

Coh3n

2010-10-26 02:50:45

Got it working! Tab acceleration works flawless (from what I've tested). Download (or update) from the following link and test it out!

[url]https://msiplayerform.googlecode.com/svn/trunk[/url]
The space on the left of the tabs (when tabs are on left) is for another tab I'm going to add. It will be a home tab which will move tab 1 to the right, and display the "Home" tab which includes some sort of introduction.

Keep in mind the code is extremely messy (all the old code is commented out), I'll get to cleaning it up when I have more time. :)

Dan Cardin

2010-10-26 21:46:40

If you click any of the middle 3 tabs a second time after you activate that tab, it freaks out if the writelns is anything to go by and it wont let you change tabs.

You could totally shorten that in the same way that I did with mine. Then again, that was probably the reason mine didn't work :P

Coh3n

2010-10-26 22:18:22

From: Dan Cardin
If you click any of the middle 3 tabs a second time after you activate that tab, it freaks out if the writelns is anything to go by and it wont let you change tabs.

Thanks. I found that happening for tabs 1 and 5, but didn't realize it was the same for all of them. This is what I did to fix 1 and 5. I should be able to write a general function to handle all of them. :)

if (i = IMG_TAB_NORM_5) then
if (isLeftTab[i]) then
Exit;

if (i = IMG_TAB_NORM_1) then
if (isLeftTab[i]) then
if (t <= 1) then
Exit;

From: Dan Cardin

You could totally shorten that in the same way that I did with mine. Then again, that was probably the reason mine didn't work :P

Oh yeah, I know I could, but I was more concerned about it working than the length. It can be shortened later if needed. :p

E: Fixed. :)

Coh3n

2010-10-27 01:19:37

Also added the home tab. Let me know what you guys think. :) The fonts not exactly the same because I don't know which font as used, nor the proper layer properties, but I think it's pretty close. :p

If you don't have a copy of the form and you're bored, SVN Checkout from here, open MSIForm.simba and hit run! :D

https://msiplayerform.googlecode.com/svn/trunk

Dan Cardin

2010-10-27 07:11:07

woops. I just noticed. you aren't displaying the panels. I can try to do this if you havent already when i get home.

Coh3n

2010-10-27 15:09:43

From: Dan Cardin
woops. I just noticed. you aren't displaying the panels. I can try to do this if you havent already when i get home.

Yeah I just made them invisible while I was getting the tabs working properly. The sizing and coordinates will need to be changed slightly, but shouldn't be a big deal. Also, do you know if you can display an image as the a TPanel background? I may have asked this before, I don't remember. :p

Oh and if you do start this, if you can get the basic stuff all working and looking pretty that would be great. Get the player list working on all tabs, the next and previous player buttons, stuff like that.

One thing I'd like to do with the form is write it so it doesn't need updating when new scripts or objects are added. I'll try to quickly write up a function or two that will be able to handle this since I don't expect you to know all the MSI arrays, etc. :p

Seems like I'll be able to commit this to the SVN soon (for testing, etc.) as it will start using vars from MSI.

Dan Cardin

2010-10-27 22:02:56

whenever i try to fix it it kills Simba and says it's going out of range when i put try things around it.

I thought i had all the next player and adding player stuff up though.

Coh3n

2010-10-27 23:23:40

From: Dan Cardin
whenever i try to fix it it kills Simba and says it's going out of range when i put try things around it.

Yeah I'm sure that was because of what I changed. I should be able to get to it sometime in the next couple days.

From: Dan Cardin

I thought i had all the next player and adding player stuff up though.

You may have, I don't remember every completely testing it. ^^

Gu3st...

2010-11-17 20:18:39

type
TMSI_Form_Player = record
Username, Password, Nickname, Pin, Member, BreakLoads, TotalLoads,
TotalTime, Active, Script, ScriptObject, Priority, DontDrop,
Location : String;
end;

const
DEBUG_SMART = True; // Debugs things onto SMART (may cause lag)
BREAK_TIME = 15; // Single player only - how long to break for (in minutes)
SAVE_DEBUG = True; // Save's the debug box text to a file
ENABLE_REMOTE = True; // Do you want to enable the Player Remote?
LEVEL_TO_DEBUG = 10; // The lower the number, the less the script will debug
HUMAN_BREAKING = True; // Take more human like breaks
ANTIBAN_MIN_WAIT = 10000; // Minimum time to wait between antibans

WORLD_SMART = 153;

STATS_ID = ''; // Temporary stats ID (2 digit number)
STATS_PASS = ''; // Temporary stats password

{$i MSI/Setup.simba}

var
MSI_MF_FormPlayers : array of TMSI_Form_Player;
MSI_MF_CurrentFormPlayer : Integer;

MSI_MainForm : TForm;

MSI_MF_ListBox : TListBox;
MSI_MF_Labels : array [0..13] of TLabel;
MSI_MF_Edits : array [0..11] of TEdit;
MSI_MF_DropDowns : array [0..2] of TComboBox;
MSI_MF_Buttons : array [0..2] of TButton;

MSI_MF_Timer : TTimer;

function BoolToInt(B : Boolean): Integer;
begin
Result := 0;
if B then Result := 1;
end;

procedure MSI_MainForm_LoadFormPlayers(WhatPlayer : Integer; SaveInfo : Boolean);
var
I : Integer;
begin
MSI_MF_CurrentFormPlayer := WhatPlayer;
if SaveInfo then
begin
MSI_MF_FormPlayers[WhatPlayer].Username := MSI_MF_Edits[0].Caption;
MSI_MF_FormPlayers[WhatPlayer].Password := MSI_MF_Edits[1].Caption;
MSI_MF_FormPlayers[WhatPlayer].Nickname := MSI_MF_Edits[2].Caption;
MSI_MF_FormPlayers[WhatPlayer].Pin := MSI_MF_Edits[3].Caption;
MSI_MF_FormPlayers[WhatPlayer].Member := MSI_MF_DropDowns[0].Caption;
MSI_MF_FormPlayers[WhatPlayer].BreakLoads := MSI_MF_Edits[4].Caption;
MSI_MF_FormPlayers[WhatPlayer].TotalLoads := MSI_MF_Edits[5].Caption;
MSI_MF_FormPlayers[WhatPlayer].TotalTime := MSI_MF_Edits[6].Caption;
MSI_MF_FormPlayers[WhatPlayer].Active := MSI_MF_DropDowns[1].Caption;
MSI_MF_FormPlayers[WhatPlayer].Script := MSI_MF_DropDowns[2].Caption;
MSI_MF_FormPlayers[WhatPlayer].ScriptObject := MSI_MF_Edits[7].Caption;
MSI_MF_FormPlayers[WhatPlayer].Priority := MSI_MF_Edits[8].Caption;
MSI_MF_FormPlayers[WhatPlayer].DontDrop := MSI_MF_Edits[9].Caption;
MSI_MF_FormPlayers[WhatPlayer].Location := MSI_MF_Edits[10].Caption;
end;

MSI_MF_ListBox.Clear;
for I := 0 to High(MSI_MF_FormPlayers) do
if MSI_MF_FormPlayers[I].Username <> '' then
MSI_MF_ListBox.Items.Add(MSI_MF_FormPlayers[I].Username)
else
MSI_MF_ListBox.Items.Add('?');

MSI_MF_ListBox.ItemIndex := WhatPlayer;
MSI_MF_Edits[0].Caption := MSI_MF_FormPlayers[WhatPlayer].Username;
MSI_MF_Edits[1].Caption := MSI_MF_FormPlayers[WhatPlayer].Password;
MSI_MF_Edits[2].Caption := MSI_MF_FormPlayers[WhatPlayer].Nickname;
MSI_MF_Edits[3].Caption := MSI_MF_FormPlayers[WhatPlayer].Pin;
MSI_MF_DropDowns[0].Caption := MSI_MF_FormPlayers[WhatPlayer].Member;
MSI_MF_Edits[4].Caption := MSI_MF_FormPlayers[WhatPlayer].BreakLoads;
MSI_MF_Edits[5].Caption := MSI_MF_FormPlayers[WhatPlayer].TotalLoads;
MSI_MF_Edits[6].Caption := MSI_MF_FormPlayers[WhatPlayer].TotalTime;
MSI_MF_DropDowns[1].Caption := MSI_MF_FormPlayers[WhatPlayer].Active;
MSI_MF_DropDowns[2].Caption := MSI_MF_FormPlayers[WhatPlayer].Script;
MSI_MF_Edits[7].Caption := MSI_MF_FormPlayers[WhatPlayer].ScriptObject;
MSI_MF_Edits[8].Caption := MSI_MF_FormPlayers[WhatPlayer].Priority;
MSI_MF_Edits[9].Caption := MSI_MF_FormPlayers[WhatPlayer].DontDrop;
MSI_MF_Edits[10].Caption := MSI_MF_FormPlayers[WhatPlayer].Location;

MSI_MF_Buttons[1].Enabled := (GetArrayLength(MSI_MF_FormPlayers) > 1);
WriteLn('yo');
end;

procedure MSI_MainForm_OnClick(Sender : TObject);
var
I : Integer;
begin
case Sender of
MSI_MF_Buttons[0]:
begin
SetArrayLength(MSI_MF_FormPlayers, GetArrayLength(MSI_MF_FormPlayers)+1);
MSI_MainForm_LoadFormPlayers(High(MSI_MF_FormPlayers), True);
end;
MSI_MF_Buttons[1]:
begin
if not MSI_MF_CurrentFormPlayer = High(MSI_MF_FormPlayers) then
if MSI_MF_CurrentFormPlayer+1 = High(MSI_MF_FormPlayers) then
MSI_MF_FormPlayers[MSI_MF_CurrentFormPlayer] := MSI_MF_FormPlayers[High(MSI_MF_FormPlayers)]
else
for I := MSI_MF_CurrentFormPlayer to High(MSI_MF_FormPlayers)-1 do
MSI_MF_FormPlayers[I] := MSI_MF_FormPlayers[I+1];
SetArrayLength(MSI_MF_FormPlayers, GetArrayLength(MSI_MF_FormPlayers)-1);
MSI_MainForm_LoadFormPlayers(High(MSI_MF_FormPlayers), False);
end;
MSI_MF_Buttons[2]:
begin
MSI_MainForm.ModalResult := mrOk;
end;
MSI_MF_ListBox:
begin
MSI_MainForm_LoadFormPlayers(MSI_MF_ListBox.ItemIndex, True);
end;
end;
end;

procedure MSI_MainForm_OnTimer(Sender : TObject);
var
I : Integer;
begin
case Sender of
MSI_MF_Timer:
begin
if MSI_MF_DropDowns[2].ItemIndex <> -1 then
begin
for I := 7 to 10 do
MSI_MF_Edits[I].Visible := True;
for I := 10 to 13 do
MSI_MF_Labels[I].Visible := True;
case MSI_MF_DropDowns[2].ItemIndex of
0..13: MSI_MF_Labels[10].Caption := 'Trees';
14..24: MSI_MF_Labels[10].Caption := 'Rocks';
25..27: MSI_MF_Labels[10].Caption := 'Fish Spots';
28..28: MSI_MF_Labels[10].Caption := 'Meals';
end;
end else
begin
for I := 7 to 10 do
MSI_MF_Edits[I].Visible := False;
for I := 10 to 13 do
MSI_MF_Labels[I].Visible := False;
end;
end;
end;
end;

procedure MSI_MainForm_InitForm;
var
LabelBounds : TBoxArray;
LabelTexts : TStringArray;
EditBounds : TBoxArray;
EditTexts : TStringArray;
DropDownBounds : TBoxArray;
DropDownTexts : array of TStringArray;
H, I, J, X : Integer;
begin
MSI_MainForm := TForm.Create(nil);
with MSI_MainForm do
begin
SetBounds({L} 100, {T} 100, {W} 600, {H} 400);
Caption := 'MSI Player Form';
if MsiRev <> '' then Caption := Caption + ' - MSI Rev #' + MsiRev + '.';
Color := 1909287;
BorderStyle := bsNone;
end;

MSI_MF_ListBox := TListBox.Create(MSI_MainForm);
with MSI_MF_ListBox do
begin
Parent := MSI_MainForm;
SetBounds(15, 105, 110, 250);
Font.Color := clWhite;
Items.Add('Player1');
Color := 2962491;
OnClick := @MSI_MainForm_OnClick;
end;

MSI_MF_Timer := TTimer.Create(MSI_MainForm);
with MSI_MF_Timer do
begin
OnTimer := @MSI_MainForm_OnTimer;
Interval := 200;
Enabled := True;
end;

SetArrayLength(LabelBounds, 14);
for I := 0 to 13 do
LabelBounds[I] := IntToBox(130+(BoolToInt(I>8)*250), 105+(I*25)-(BoolToInt(I>8)*225), 100, 20);
LabelTexts := [
'Username',
'Password',
'Nickname',
'Pin',
'Member',
'BreakLoads',
'TotalLoads',
'TotalTime',
'Active',
'Script',
'$(SCRIPT_OBJECT)',
'Priority',
'DontDrop',
'Location'
];
for I := 0 to 13 do
begin
MSI_MF_Labels[I] := TLabel.Create(MSI_MainForm);
with MSI_MF_Labels[I] do
begin
Parent := MSI_MainForm;
SetBounds(LabelBounds[I].X1, LabelBounds[I].Y1, LabelBounds[I].X2, LabelBounds[I].Y2);
Caption := LabelTexts[I];
with Font do
begin
Color := clWhite;
Size := 12;
end;
end;
end;

SetArrayLength(EditBounds, 11);
for I := 0 to 10 do
case I of
0..3: EditBounds[I] := IntToBox(235, 105+((I-0)*25), 100, 20);
4..6: EditBounds[I] := IntToBox(235, 230+((I-4)*25), 100, 20);
7..10: EditBounds[I] := IntToBox(485, 130+((I-7)*25), 100, 20);
end;
EditTexts := [
'Player1',
'*****',
'laye',
'',
'0',
'0',
'0',
'',
'',
'',
''
];

for I := 0 to 10 do
begin
MSI_MF_Edits[I] := TEdit.Create(MSI_MainForm);
with MSI_MF_Edits[I] do
begin
Parent := MSI_MainForm;
SetBounds(EditBounds[I].X1, EditBounds[I].Y1, EditBounds[I].X2, EditBounds[I].Y2);
Text := EditTexts[I];
Color := 2962491;
Font.Color := clWhite;
case I of
1: PasswordChar := '*';
3: MaxLength := 4;
end;
if I > 6 then Visible := False;
end;
end;

SetArrayLength(DropDownBounds, 3);
for I := 0 to 3 do
case I of
0: DropDownBounds[I] := IntToBox(235, 205, 100, 20);
1: DropDownBounds[I] := IntToBox(235, 305, 100, 20);
2: DropDownBounds[I] := IntToBox(435, 105, 150, 20);
end;
SetArrayLength(DropDownTexts, 3);
for I := 0 to 2 do
case I of
0: DropDownTexts[I] := ['Yes', 'No'];
1: DropDownTexts[I] := ['Yes', 'No'];
2: begin
H := SCRIPT_ARRAY_LENGTH;
for J := 0 to H do
begin
if MSI_Scripts[J].Name <> '' then
begin
SetArrayLength(DropDownTexts[I], X+1);
DropDownTexts[I][X] := MSI_Scripts[J].Name;
Inc(X);
end;
end;
end;
end;

for I := 0 to 2 do
begin
MSI_MF_DropDowns[I] := TComboBox.Create(MSI_MainForm);
with MSI_MF_DropDowns[I] do
begin
Parent := MSI_MainForm;
SetBounds(DropDownBounds[I].X1, DropDownBounds[I].Y1, DropDownBounds[I].X2, DropDownBounds[I].Y2);
Color := 2962491;
Font.Color := clWhite;
H := High(DropDownTexts[I]);
with Items do
begin
for J := 0 to H do
Add(DropDownTexts[I][J]);
end;
end;
end;

for I := 0 to 2 do
begin
MSI_MF_Buttons[I] := TButton.Create(MSI_MainForm);
with MSI_MF_Buttons[I] do
begin
Parent := MSI_MainForm;
case I of
0: SetBounds(15, 360, 30, 30);
1: SetBounds(95, 360, 30, 30);
2: SetBounds(525, 355, 60, 30);
end;
case I of
0: Caption := '+';
1: Caption := '-';
2: Caption := 'START';
end;
if I = 1 then Enabled := False;
OnClick := @MSI_MainForm_OnClick;
end;
end;

end;

procedure MSI_MainForm_SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('MSI_MainForm_InitForm', v);
end;

procedure MSI_MainForm_ShowMainFormModal;
begin
MSI_MainForm.ShowModal;
end;

procedure MSI_MainForm_SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('MSI_MainForm_ShowMainFormModal', v);
end;

begin
SetupMSI;
SetArrayLength(MSI_MF_FormPlayers, 1);
try
MSI_MainForm_SafeInitForm;
MSI_MainForm_SafeShowFormModal;
finally
MSI_MainForm.Free;
except
Writeln(ExceptionToString(ExceptionType, ExceptionParam));
end;
end.
I've started on the temp form, but I've gotten stuck at player loading using the ListBox thing..
I used MasterKill's THE big form tutorial, but I must've done something wrong.. >_<

Coh3n

2010-11-18 01:05:42

What's the error and where do you get it? Or are you just stuck as in you don't know what to do next?

E: You could probably make the current form work (SVN link on first post) as it's just some basic form knowledge and player saving/loading that needs to be done. I fixed the issue with the tabs, which is why development was halted in the first place.

Gu3st...

2010-11-18 02:33:35

From: Coh3n
What's the error and where do you get it? Or are you just stuck as in you don't know what to do next?

The problem is that when you click one of the players from the listbox, what should actually happen, is that the TEdits and TComboBoxes should change their information to the correct information, but as it is now, clicking one of the players makes the script override the player selected with the TEdits and TComboBoxes…

It was like 02:20 am when I worte that post, by the way, so I didn't want to do debugging and that sort of stuff.. Going to do it now..

From: Coh3n
E: You could probably make the current form work (SVN link on first post) as it's just some basic form knowledge and player saving/loading that needs to be done. I fixed the issue with the tabs, which is why development was halted in the first place.

I'll take a look at it :)

E: Tabs are still bugging for me.. Try clicking on tab 5 then on tab 2

Coh3n

2010-11-18 02:58:45

From: Zyt3x
The problem is that when you click one of the players from the listbox, what should actually happen, is that the TEdits and TComboBoxes should change their information to the correct information, but as it is now, clicking one of the players makes the script override the player selected with the TEdits and TComboBoxes…

Are you storing it all the player information in arrays?

From: Zyt3x

E: Tabs are still bugging for me.. Try clicking on tab 5 then on tab 2


Oh, my mistake. I haven't finished making the panel sliding work properly yet. If you make all the panels invisible, the tabs will work; however, the panels need to be visible to see the setup stuff.

The first step would be to make the panels slide properly, but since I wrote the sliding I don't expect you to try and work with unfamiliar code. You can try, of course, but don't feel overwhelmed if you can't figure it out. There is a lot of code in the form that I don't even know; it's pretty confusing. :p

Gu3st...

2010-11-18 03:03:00

From: Coh3n
Are you storing it all the player information in arrays?

Yes

From: Coh3n

Oh, my mistake. I haven't finished making the panel sliding work properly yet. If you make all the panels invisible, the tabs will work; however, the panels need to be visible to see the setup stuff.

The first step would be to make the panels slide properly, but since I wrote the sliding I don't expect you to try and work with unfamiliar code. You can try, of course, but don't feel overwhelmed if you can't figure it out. There is a lot of code in the form that I don't even know; it's pretty confusing. :p
Yeah, I've tried to understand the MSI Form a numerous of times >_<

Dan Cardin

2010-11-18 22:17:05

yea…Whoever originally wrote the mousemove stuff was crazy. This kind of thing is why I don't like dealing with images only. It does look better, but it is a lot more difficult to manage.

EDIT: erm…I dont know why I didn't think of this before, but why don't we just do like…

for i := TAB_IMAGE_1 to high(panels) do
begin
panel[i].left := image[i].left + image[i].width + 2
if i <> high(Panels) then
panel[i].width := image[i + 1].left - 2
else
panel[i].width := form.width - 2;
end;
You know? None of those variables are right and stuff, but The idea is there. Seems to me like that would work better than trying to animate it independently. And im sure there's a way to single out the two panels that need animating rather than doing them all.

Coh3n

2010-11-18 22:28:34

From: Dan Cardin
yea…Whoever originally wrote the mousemove stuff was crazy. This kind of thing is why I don't like dealing with images only. It does look better, but it is a lot more difficult to manage.

You're right. I think we should have made a basic form that worked first, then made it better afterwards.

From: Dan Cardin

EDIT: erm…I dont know why I didn't think of this before, but why don't we just do like…

for i := TAB_IMAGE_1 to high(panels) do
begin
panel[i].left := image[i].left + image[i].width + 2
if i <> high(Panels) then
panel[i].width := image[i + 1].left - 2
else
panel[i].width := form.width - 2;
end;
You know? None of those variables are right and stuff, but The idea is there. Seems to me like that would work better than trying to animate it independently. And im sure there's a way to single out the two panels that need animating rather than doing them all.

Try it out. I can't remember exactly how it works, and I haven't had the chance to look at the panel animation again.

Dan Cardin

2010-11-19 07:14:55

program MSIForm;

const
IMG_COUNT = 25;
// Used in frmMain
IMG_BGND = 0;
IMG_X_NORM = 1;
IMG_Q_NORM = 2;
IMG_LOAD_TAB_NORM = 3;
IMG_SAVE_TAB_NORM = 4;
IMG_TAB_NORM_1 = 5;
IMG_TAB_NORM_2 = 6;
IMG_TAB_NORM_3 = 7;
IMG_TAB_NORM_4 = 8;
IMG_TAB_NORM_5 = 9;

// Used in Panel 0 (Is also used for frmMain)
IMG_LOC_ICON_NORM = 10;
IMG_LOC_EXIT_NORM = 11;
IMG_LOC_MAP = 12;
IMG_LOC_NAV = 13;
IMG_LOC_BORD_TOP = 14;
IMG_LOC_BORD_BOTTOM = 15;
IMG_LOC_BORD_LEFT = 16;
IMG_LOC_BORD_RIGHT = 17;
IMG_LOC_BOX_TOP = 18;
IMG_LOC_BOX_LEFT = 19;
IMG_LOC_BOX_RIGHT = 20;
IMG_LOC_BOX_BOTTOM = 21;

IMG_LOC_LABEL = 22;
IMG_TAB_HINT = 23;

IMG_TAB_NORM_0 = 24;

PANEL_NUM = 5;
// Used in Panel 1

// Used in Panel 2

// Used in Panel 3

// Used in Panel 4

BITMAP_COUNT = 35;
BGND = 0;
X_NORM = 1;
X_HOVER = 2;
Q_NORM = 3;
Q_HOVER = 4;
LOAD_TAB_NORM = 5;
LOAD_TAB_HOVER = 6;
SAVE_TAB_NORM = 7;
SAVE_TAB_HOVER = 8;
TAB_NORM_1 = 9;
TAB_HOVER_1 = 10;
TAB_NORM_2 = 11;
TAB_HOVER_2 = 12;
TAB_NORM_3 = 13;
TAB_HOVER_3 = 14;
TAB_NORM_4 = 15;
TAB_HOVER_4 = 16;
TAB_NORM_5 = 17;
TAB_HOVER_5 = 18;
LOC_ICON_NORM = 19;
LOC_ICON_HOVER = 20;
LOC_EXIT_NORM = 21;
LOC_EXIT_HOVER = 22;
LOC_MAP = 23;
LOC_NAV = 24;
LOC_BORD_TOP = 25;
LOC_BORD_BOTTOM = 26;
LOC_BORD_LEFT = 27;
LOC_BORD_RIGHT = 28;
LOC_BOX_TOP = 29;
LOC_BOX_LEFT = 30;
LOC_LABEL = 31;
TAB_HINT = 32;
TAB_NORM_0 = 33;
TAB_HOVER_0 = 34;

var
frmMain: TForm;
time: TTimer;

tImages: Array[0..IMG_COUNT - 1] of TImage;

frmBitmaps: Array [0..BITMAP_COUNT - 1] of Integer;

isActiveImage: Array[0..IMG_COUNT - 1] of Boolean;
isLeftTab: Array[IMG_TAB_NORM_1..IMG_TAB_NORM_5] of Boolean;

MapDragStartX, MapDragStartY: Integer;

panels: array [IMG_TAB_NORM_1..IMG_TAB_NORM_1 + PANEL_NUM - 1] of TPanel;





var //Panel 2
UserList: TCheckListBox;
User, Pass: TEdit;
Button1,Button2: TButton;
Label_2, label2_2: TLabel;
var //Panel 3
ComboBox_3: TComboBox;
Add_3, Delete_3: TButton;
CheckListBox_3: TCheckListBox;
var //Panel 4
ComboBox_4: TComboBox;
Add_4, Delete_4: TButton;
CheckListBox_4: TCheckListBox;
var //Panel 5
Label_5, Label2_5: TLabel;
ComboBox_5: TComboBox;
Add_5, Delete_5: TButton;
Edit_5, Edit2_5: TEdit;


procedure OutsideBox(l,t,r,b, obj: integer);
begin
if tImages[obj].Left > l then
tImages[obj].Left := l;
if tImages[obj].Top > t then
tImages[obj].Top := t;
if tImages[obj].Left < r then
tImages[obj].Left := r;
if tImages[obj].Top < b then
tImages[obj].Top := b;
end;

procedure DDrawBitmap(Bmp: Longint; dest: TCanvas; x,y: integer);
begin
{$IFDEF SIMBA}
DrawBitmap(Bmp,dest,x,y);
{$ELSE}
SafeDrawBitmap(Bmp,dest,x,y);
{$ENDIF}
end;

function IsMouseButtonDow(yes: LongInt): boolean;
begin
{$IFDEF SIMBA}
result := IsMouseButtonDown(yes);
{$ELSE}
if yes = 1 then
result := IsMouseButtonDown(True)
else
result := IsMouseButtonDown(False);
{$ENDIF}
end;

procedure OnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
BoundL, BoundT: Extended;
begin
case sender of
tImages[IMG_LOC_MAP]:
begin
MapDragStartX := x;
MapDragStartY := y;
end;
tImages[IMG_LOC_NAV]:
begin
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x + (x - left), {T} y + (y - top), {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

OutsideBox(0,0,-345, -354, IMG_LOC_MAP);
end;
end;
end;

procedure IntroVisible(Visible: Boolean);
begin
// Show/hide components on the introduction tab
if (not Visible) then
begin
tImages[IMG_LOC_ICON_NORM].Visible := False;
tImages[IMG_LOC_LABEL].Visible := False;
tImages[IMG_TAB_HINT].Visible := False;
end else begin
tImages[IMG_LOC_ICON_NORM].Visible := True;
tImages[IMG_LOC_LABEL].Visible := True;
tImages[IMG_TAB_HINT].Visible := True;
end;
end;

const
MAX_MOVE = 315;

var
accel, move, senderTab, pan: integer;
cons: array [IMG_TAB_NORM_1..IMG_TAB_NORM_1 + PANEL_NUM - 1] of integer;
onLeft: Boolean;

procedure TimerTabClick(Sender: TObject);
var
i, e, d, hi, lo: Integer;
begin
accel := accel + 2;
move := move + accel;

if (senderTab = IMG_TAB_NORM_0) then
begin
for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_5 do
begin
if (not isLeftTab[i]) then
Continue;

tImages[i].Left := tImages[i].Left + accel;

if (move >= MAX_MOVE) then
begin
isLeftTab[i] := False;
time.Enabled := False;
tImages[i].Left := tImages[i].Left - 5;
IntroVisible(True);
end;
end;

Exit;
end;

if (onLeft) then
for i := senderTab to IMG_TAB_NORM_5 do
begin
if (i = senderTab) or (not isLeftTab[i]) then
Continue;

tImages[i].Left := tImages[i].Left + accel;

if (move >= MAX_MOVE) then
begin
isLeftTab[i] := False;
time.Enabled := False;
tImages[i].Left := tImages[i].Left - 5;
end;

Writeln(BoolToStr(isLeftTab[i]));
end
else
for i := senderTab downto IMG_TAB_NORM_1 do
begin
if (isLeftTab[i]) then
Continue;

tImages[i].Left := tImages[i].Left - accel;

if (move >= MAX_MOVE) then
begin
isLeftTab[i] := True;
time.Enabled := False;
tImages[i].Left := tImages[i].Left + 5;
end;

IntroVisible(False);
end;

for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_5 do
Writeln('Tab'+IntToStr(i)+': '+ BoolToStr(isLeftTab[i]));


for i := IMG_TAB_NORM_1 to high(panels) do
begin
panels[i].left := tImages[i].left + tImages[i].width + 2
if i <> high(Panels) then
panels[i].width := tImages[i + 1].left - panels[i].left - 2
else
panels[i].width := frmMain.width - panels[i].left - 10;
end;

{ if pan < senderTab then
begin
panels[pan].width := panels[pan].width - accel;
panels[senderTab].left := panels[senderTab].left - accel;
panels[senderTab].width := panels[senderTab].width + accel;
if move >= 377 then
begin
panels[sendertab].left := cons[sendertab] + 377 * d + tImages[sendertab].width;
panels[senderTab].width := 377;
end;
end;
if pan > senderTab then
begin
panels[pan].left := panels[pan].left + accel;
panels[pan].width := panels[pan].width - accel;
panels[senderTab].width := panels[senderTab].width + accel;
if move >= 377 then
begin
panels[pan].width := 0;
panels[sendertab].width := 377;
end;
end;}
end;

procedure TabClick(Sender: TObject);
var
i: integer;
begin
if not time.ENABLED then
begin
accel := 0;
move := 0;
time.enabled := true;
pan := senderTab;

if (Sender = tImages[IMG_TAB_NORM_0]) then
senderTab := IMG_TAB_NORM_0;

for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_5 do
if (Sender = tImages[i]) then
begin
senderTab := i;
if (isLeftTab[senderTab]) then
onLeft := True
else
onLeft := False;
end;
end;
end;

procedure LocViewer(Sender: TObject);
var
i: Integer;
am: TintegerArray;
tru: boolean;
begin
am := [IMG_LOC_ICON_NORM, IMG_TAB_HINT, IMG_LOC_LABEL, IMG_TAB_NORM_0];

case Sender of
tImages[IMG_LOC_ICON_NORM]: begin
tru := true;
for i := low(panels) to high(panels) do
panels[i].visible := false;
end;
tImages[IMG_LOC_EXIT_NORM]: begin
tru := false;
//for i := low(panels) to high(panels) do
//panels[i].visible := true;
end;
end;

for i := IMG_LOC_EXIT_NORM to IMG_LOC_BOX_BOTTOM do
tImages[i].Visible := tru;

for i := 0 to high(am) do
tImages[am[i]].Visible := not tru;
end;

procedure Clicked(Sender: TObject);
var
i: Integer;
begin
for i := 0 to BITMAP_COUNT - 1 do
FreeBitmap(frmBitmaps[i]);
frmMain.ModalResult := mrOk;
end;

procedure MouseMoved(Sender: TObject; Shift: TShiftState; x, y: Integer);
var
hi, i, bmp, xdif, ydif, h: Integer;
BoundL, BoundT: Extended;
imgSwap, bmpArr, imgArr: Array of Integer;
begin
bmpArr := [ X_NORM, Q_NORM, LOAD_TAB_NORM,
SAVE_TAB_NORM, TAB_NORM_1, TAB_NORM_2,
TAB_NORM_3, TAB_NORM_4, TAB_NORM_5, LOC_ICON_NORM, LOC_EXIT_NORM,
TAB_NORM_0 ];

imgArr := [ IMG_X_NORM, IMG_Q_NORM, IMG_LOAD_TAB_NORM,
IMG_SAVE_TAB_NORM, IMG_TAB_NORM_1, IMG_TAB_NORM_2,
IMG_TAB_NORM_3, IMG_TAB_NORM_4, IMG_TAB_NORM_5, IMG_LOC_ICON_NORM,
IMG_LOC_EXIT_NORM, IMG_TAB_NORM_0 ];

hi := High(bmpArr);
case Sender of
tImages[IMG_BGND], tImages[IMG_LOC_MAP]:
begin
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;

bmp := frmBitmaps[bmpArr[i]];
DDrawBitmap(bmp,tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;
end;
for h := 0 to hi do
case Sender of
tImages[imgArr[h]]:
begin
imgSwap := [imgArr[h], frmBitmaps[bmpArr[h] + 1]];
if not (isActiveImage[imgSwap[0]]) then
begin
DDrawBitmap(imgSwap[1],tImages[imgSwap[0]].Canvas,0,0);
isActiveImage[imgSwap[0]] := True;
for i := 0 to hi do
begin
if (Sender = tImages[imgArr[i]]) then
Continue;

if (not isActiveImage[imgArr[i]]) then
Continue;

if (i = imgSwap[0] - 1) then
Continue;

if imgSwap[0] = IMG_LOC_EXIT_NORM then
if (i = imgSwap[0]) then
Continue;

if imgSwap[0] = IMG_LOC_ICON_NORM then
if (i = imgSwap[0] - 10) then
Continue;

bmp := frmBitmaps[bmpArr[i]];
DDrawBitmap(bmp, tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;
end;
end;
case sender of
tImages[IMG_LOC_MAP]:
begin
if not IsMouseButtonDow(1) then exit;
xdif := x - MapDragStartX;
ydif := y - MapDragStartY;
tImages[IMG_LOC_MAP].Left := tImages[IMG_LOC_MAP].Left + xdif;
tImages[IMG_LOC_MAP].Top := tImages[IMG_LOC_MAP].Top + ydif;

OutsideBox(0,0,-854, -765, IMG_LOC_MAP);

BoundL := -tImages[IMG_LOC_MAP].Left / 7.234 + 376;
BoundT := -tImages[IMG_LOC_MAP].Top / 7.234 + 216;


with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} Round(BoundL), {T} Round(BoundT), {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);
end;
tImages[IMG_LOC_NAV]:
begin
if not IsMouseButtonDow(1) then exit;
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x - 55 - 100, {T} y - 40 - 100, {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

OutsideBox(0, 0, -854, -765, IMG_LOC_MAP);
end;
end;
end;

procedure OnClickEvents(Sender: TObject);
var
i, t: integer;
begin
for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_5 do
if (isLeftTab[i]) then
Inc(t);

for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_5 do
case Sender of
tImages[i]:
begin
if (isLeftTab[i]) then
if (t <= (i - (IMG_TAB_NORM_5 - IMG_TAB_NORM_1))) then
Exit;

TabClick(Sender);
end;
end;

case Sender of
tImages[IMG_X_NORM]: Clicked(Sender);
tImages[IMG_LOC_ICON_NORM], tImages[IMG_LOC_EXIT_NORM]: LocViewer(Sender);

tImages[IMG_TAB_NORM_0]:
begin
if (t <= 0) then
Exit;

TabClick(Sender);
end;
end;
end;

procedure Panel2Clicks(Sender: TObject);
var sel: integer;
begin
case sender of
Button1: begin
UserList.Items.Append(User.Text + ' (' + Pass.Text + ')');
combobox_3.items.append(User.Text);
combobox_4.items.append(User.Text);
UserList.Checked[UserList.items.Count - 1] := true;
UserList.ItemIndex := UserList.items.Count - 1;
User.Text := '';
Pass.Text := '';
end;
Button2: begin
if UserList.ItemIndex >= 0 then
sel := UserList.ItemIndex;
UserList.Items.Delete(sel);
combobox_3.Items.Delete(sel);
combobox_4.Items.Delete(sel);
if sel = 0 then
sel := 1;
UserList.ItemIndex := sel - 1;
User.Text := '';
Pass.Text := '';
end;
UserList: begin
User.Text := UserList.items.strings[UserList.ItemIndex];
Pass.Text := UserList.items.strings[UserList.ItemIndex];
end;
end;
end;

procedure Panel3Clicks(Sender: TObject);
begin
case sender of
Add_3: begin
if Combobox_3.ITEMINDEX > 0 then
combobox_3.ItemIndex := combobox_3.ItemIndex - 1;
end;
Combobox_3: begin
end;
Delete_3: begin
if Combobox_3.ITEMINDEX < Combobox_3.ITEMS.Count then
combobox_3.ItemIndex := combobox_3.ItemIndex + 1;
end;
end;
end;

procedure Panel4Clicks(Sender: TObject);
begin
case sender of
Add_4: begin
if Combobox_4.ITEMINDEX > 0 then
combobox_4.ItemIndex := combobox_4.ItemIndex - 1;
end;
Combobox_4: begin
end;
Delete_4: begin
if Combobox_4.ITEMINDEX < Combobox_4.ITEMS.Count then
combobox_4.ItemIndex := combobox_4.ItemIndex + 1;
end;
end;
end;

procedure Panel2Clic(Sender: TObject; Index: Integer);
begin

end;

procedure InitForm;
var
i, pan: Integer;
consts: TintegerArray;
bmpArr: TStringArray;
xy: TPointArray;
visibl: array of boolean;
wh: TPoint;
begin
bmpArr := ['BGND','X_NORM','X_HOVER','Q_NORM','Q_HOVER','LOAD_TAB_NORM','LOAD_TAB_HOVER','SAVE_TAB_NORM','SAVE_TAB_HOVER','TAB_NORM_1','TAB_HOVER_1','TAB_NORM_2','TAB_HOVER_2','TAB_NORM_3','TAB_HOVER_3','TAB_NORM_4','TAB_HOVER_4','TAB_NORM_5','TAB_HOVER_5','LOC_ICON_NORM','LOC_ICON_HOVER','LOC_EXIT_NORM','LOC_EXIT_HOVER','LOC_MAP','LOC_NAV','LOC_BORD_TOP','LOC_BORD_BOTTOM','LOC_BORD_LEFT','LOC_BORD_RIGHT','LOC_BOX_TOP','LOC_BOX_LEFT','LOC_LABEL','TAB_HINT','TAB_NORM_0','TAB_HOVER_0'];
for i := 0 to High(frmBitmaps) do
frmBitmaps[i] := LoadBitmap(ScriptPath + 'Bitmaps\' + bmpArr[i] + '.png');

frmMain := TForm.Create(nil);
frmMain.SetBounds({L} 100, {T} 100, {W} 600, {H} 400);
frmMain.Position := poScreenCenter;
frmMain.BorderStyle := bsNone;

time := TTimer.Create(frmMain);
with time do
begin
ONTIMER := @TimerTabClick;
INTERVAL := 10;
ENABLED := false;
end;

xy := [Point(0,0), Point(575,7), Point(557,7), Point(7,69), Point(81,69), Point(386, 100), Point(427,100), Point(468,100), Point(509,100), Point(550,100), Point(165,220), Point(475,7), Point(-300,0), Point(369,209), Point(0,0), Point(0,393), Point(0,7), Point(593,7), Point(Round( 300 / 7.234 + 376), 216), Point(Round( 300 / 7.234 + 376), 216 + 1), Point(Round( 300 / 7.234 + 376) + 83, 216 + 1), Point(Round( 300 / 7.234 + 376), 216 + 1 + 54), Point(142,262), Point(100,379), Point(8, 222) ];
SetArrayLength(visibl, GetArrayLength(xy));
visibl := [true, true, true, true, true, true, true, true, true, true, True, false, false, false, false, false, false, false, false, false, false, false, true, true, True ];
consts := [BGND, X_NORM, Q_NORM, LOAD_TAB_NORM,SAVE_TAB_NORM,TAB_NORM_1, TAB_NORM_2, TAB_NORM_3, TAB_NORM_4, TAB_NORM_5, LOC_ICON_NORM, LOC_EXIT_NORM, LOC_MAP, LOC_NAV, LOC_BORD_TOP, LOC_BORD_BOTTOM, LOC_BORD_LEFT, LOC_BORD_RIGHT, LOC_BOX_TOP, LOC_BOX_LEFT, LOC_BOX_LEFT, LOC_BOX_TOP, LOC_LABEL, TAB_HINT, TAB_NORM_0 ];

for i := low(panels) to high(panels) do
begin
panels[i] := TPanel.Create(frmMain);
panels[i].parent := frmMain;
GetBitmapSize(frmBitmaps[consts[i]], wh.x, wh.y);
panels[i].SetBounds(xy[i].x + wh.x, xy[i].y, 0, wh.y);
panels[i].BEVELWIDTH := 0;
// panels[i].COLOR := 1909544;
// panels[i].visible := false;
end;

for i := 0 to IMG_COUNT - 1 do
begin
tImages[i] := TImage.Create(frmMain)
with tImages[i] do
begin
Parent := frmMain;
GetBitmapSize(frmBitmaps[consts[i]], wh.x, wh.y);
SetBounds(xy[i].x, xy[i].y, wh.x, wh.y);
OnMouseMove := @MouseMoved;
ONMOUSEDOWN := @OnMouseDown;
OnClick := @OnClickEvents;
isActiveImage[i] := False;
visible := Visibl[i];
end;
DDrawBitmap(frmBitmaps[consts[i]], tImages[i].canvas, 0, 0);
end;

pan := IMG_TAB_NORM_1;

UserList := TCheckListBox.Create(panels[pan]);
UserList.Parent := panels[pan];
UserList.SetBounds(24,40,225,241);
//UserList.OnItemClick := @Panel2Clic;

Label_2 := TLabel.Create(panels[pan]);
Label_2.Parent := panels[pan];
Label_2.Setbounds(260,50,50,13);
Label_2.Caption := 'Username';

User := TEdit.Create(panels[pan]);
User.Parent := panels[pan];
User.SetBounds(260,Label_2.top + Label_2.height + 4,105,21);

Label2_2 := TLabel.Create(panels[pan]);
Label2_2.Parent := panels[pan];
Label2_2.Setbounds(260,User.top + User.height + 10,32,13);
Label2_2.Caption := 'Password';

Pass := TEdit.Create(panels[pan]);
Pass.Parent := panels[pan];
Pass.SetBounds(260,Label2_2.top + Label2_2.height + 4,105,21);

Button1 := TButton.Create(panels[pan]);
Button1.Parent := panels[pan];
Button1.Setbounds(24,8,107,25);
Button1.Caption := 'Add Player';
Button1.ONCLICK := @Panel2Clicks;

Button2 := TButton.Create(panels[pan]);
Button2.Parent := panels[pan];
Button2.SetBounds(144,8,107,25);
Button2.Caption := 'Remove Player';
Button2.OnClick := @Panel2Clicks;





pan := IMG_TAB_NORM_2;

Add_3 := TButton.Create(panels[pan]);
Add_3.Parent := panels[pan];
Add_3.SetBounds(5,5,73,25);
Add_3.Caption := 'Previous';
Add_3.OnClick := @Panel3Clicks;

ComboBox_3 := TComboBox.Create(panels[pan]);
ComboBox_3.Parent := panels[pan];
ComboBox_3.SetBounds(add_3.left + add_3.width + 5,5,105,21);
ComboBox_3.Text := 'Player';
ComboBox_3.OnClick := @Panel3Clicks;

Delete_3 := TButton.Create(panels[pan]);
Delete_3.Parent := panels[pan];
Delete_3.SetBounds(ComboBox_3.left + ComboBox_3.width + 5,5,75,25);
Delete_3.Caption := 'Next';
Delete_3.OnClick := @Panel3Clicks;

CheckListBox_3 := TCheckListBox.Create(panels[pan]);
CheckListBox_3.Parent := panels[pan];
CheckListBox_3.SetBounds(8,40,365,245);
CheckListBox_3.Items.Append('Woodcutting');
CheckListBox_3.Items.Append('---Varrok East');
CheckListBox_3.Items.Append('---Draynor');
CheckListBox_3.Items.Append('---Port Sarim');
CheckListBox_3.Items.Append('Mining');
CheckListBox_3.Items.Append('---Lumbridge Swamp');
CheckListBox_3.Items.Append('------East');
CheckListBox_3.Items.Append('------West');




pan := IMG_TAB_NORM_3;

Add_4 := TButton.Create(panels[pan]);
Add_4.Parent := panels[pan];
Add_4.SetBounds(5,5,73,25);
Add_4.Caption := 'Previous';
Add_4.OnClick := @Panel4Clicks;

ComboBox_4 := TComboBox.Create(panels[pan]);
ComboBox_4.Parent := panels[pan];
ComboBox_4.SetBounds(add_4.left + add_4.width + 5,5,105,21);
ComboBox_4.Text := 'Player';
ComboBox_4.OnClick := @Panel4Clicks;

Delete_4 := TButton.Create(panels[pan]);
Delete_4.Parent := panels[pan];
Delete_4.SetBounds(ComboBox_4.left + ComboBox_4.width + 5,5,75,25);
Delete_4.Caption := 'Next';
Delete_4.OnClick := @Panel4Clicks;

CheckListBox_4 := TCheckListBox.Create(panels[pan]);
CheckListBox_4.Parent := panels[pan];
CheckListBox_4.SetBounds(8,40,365,245);




pan := IMG_TAB_NORM_4;

Add_5 := TButton.Create(panels[pan]);
Add_5.Parent := panels[pan];
Add_5.SetBounds(5,5,73,25);
Add_5.Caption := 'Previous';

ComboBox_5 := TComboBox.Create(panels[pan]);
ComboBox_5.Parent := panels[pan];
ComboBox_5.SetBounds(add_5.left + add_5.width + 5,5,105,21);
ComboBox_5.Text := 'Player';

Delete_5 := TButton.Create(panels[pan]);
Delete_5.Parent := panels[pan];
Delete_5.SetBounds(ComboBox_5.left + ComboBox_5.width + 5,5,75,25);
Delete_5.Caption := 'Next';

Label_5 := TLabel.Create(panels[pan]);
with Label_5 do
begin
Parent := panels[pan];
Setbounds(5,Add_5.top + Add_5.height + 10,32,13);
Caption := 'Loads Before Switching Players:';
end;
Edit_5 := TEdit.Create(panels[pan]);
with Edit_5 do
begin
Parent := panels[pan];
SetBounds(5,Label_5.top + Label_5.height + 4,150,13);
end;
Label2_5 := TLabel.Create(panels[pan]);
with Label2_5 do
begin
Parent := panels[pan];
Setbounds(5,Edit_5.top + Edit_5.height + 15,32,13);
Caption := 'Total Loads:';
end;
Edit2_5 := TEdit.Create(panels[pan]);
with Edit2_5 do
begin
Parent := panels[pan];
SetBounds(5,Label2_5.top + Label2_5.height + 4,150,13);
end;






//isLeftTab[IMG_TAB_NORM_1] := true;
//panels[IMG_TAB_NORM_1].width := 377;
tImages[11].BringToFront;
//senderTab := IMG_TAB_NORM_1;
end;

procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;

procedure ShowFormModal;
begin
frmMain.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;

begin
//ClearDebug;
try
SafeInitForm;
SafeShowFormModal;
finally
time.ENABLED := false;
time.Free;
frmMain.Free;
except
Writeln(ExceptionToString(ExceptionType, ExceptionParam));
end;
end.
works all except for the >> tab. If its not already a separate tab code-wise, then it should be, which is why i assume it doesnt work like the rest of the tabs.

EDIT: yea, because you put the >> tab at the end of the numbers, it doesnt work well with the logic because of all the for loops. If we just treated it as a normal tab, the logic should apply the same way as everything else. However, I don't see the point of that tab. All it holds is the locviewer, which really isn't a big deal (as well as it doesn't completely work, and it serves absolutely no purpose). I don't see what the problem was with having it off tab up top like i did a bit ago.

Coh3n

2010-11-19 18:56:44

From: Dan
However, I don't see the point of that tab. All it holds is the locviewer, which really isn't a big deal (as well as it doesn't completely work, and it serves absolutely no purpose). I don't see what the problem was with having it off tab up top like i did a bit ago.

Because the images weren't made to blend in with the top bar, and I think it looked really ugly. Also, the form isn't done…

The >> tabs is meant to hold the "Home" tab where there will eventually be some kind of introduction to MSI, credits, or something similar. The reason I didn't treat it as a tab is because I didn't think I needed to, which from what I was doing - making just the tabs work - I didn't. If, with the panels, it will work better as one of the tabs, then sure, by all means add it to the array.

E: The >> tabs doesn't work because the panels just need to be added to it's OnClick attribute. Shouldn't be hard at all.

Dan Cardin

2010-11-20 07:14:31

well, actually, you would need to put its constant before all the others, then change all the logics to use NORM_0 instead of 1, and such. It would still be relatively easy afaik, but not a 2 second thing. (i hope)

Coh3n

2010-11-20 15:38:32

From: Dan Cardin
well, actually, you would need to put its constant before all the others, then change all the logics to use NORM_0 instead of 1, and such. It would still be relatively easy afaik, but not a 2 second thing. (i hope)

Sounds about right. You'd probably also have to add it in the sliding routines so it doesn't accelerate to the right when clicked (I think), not 100% about that though.

Dan Cardin

2010-11-21 09:21:23

apparently I lied. It isn't so easy, unless im just doing it wrong. I suppose if you cant get it to work, it would work as is, but it will be less neat.

which would be this -
program MSIForm;

const
IMG_COUNT = 25;
// Used in frmMain
IMG_BGND = 0;
IMG_X_NORM = 1;
IMG_Q_NORM = 2;
IMG_LOAD_TAB_NORM = 3;
IMG_SAVE_TAB_NORM = 4;
IMG_TAB_NORM_1 = 5;
IMG_TAB_NORM_2 = 6;
IMG_TAB_NORM_3 = 7;
IMG_TAB_NORM_4 = 8;
IMG_TAB_NORM_5 = 9;

// Used in Panel 0 (Is also used for frmMain)
IMG_LOC_ICON_NORM = 10;
IMG_LOC_EXIT_NORM = 11;
IMG_LOC_MAP = 12;
IMG_LOC_NAV = 13;
IMG_LOC_BORD_TOP = 14;
IMG_LOC_BORD_BOTTOM = 15;
IMG_LOC_BORD_LEFT = 16;
IMG_LOC_BORD_RIGHT = 17;
IMG_LOC_BOX_TOP = 18;
IMG_LOC_BOX_LEFT = 19;
IMG_LOC_BOX_RIGHT = 20;
IMG_LOC_BOX_BOTTOM = 21;

IMG_LOC_LABEL = 22;
IMG_TAB_HINT = 23;

IMG_TAB_NORM_0 = 24;

PANEL_NUM = 5;
// Used in Panel 1

// Used in Panel 2

// Used in Panel 3

// Used in Panel 4

BITMAP_COUNT = 35;
BGND = 0;
X_NORM = 1;
X_HOVER = 2;
Q_NORM = 3;
Q_HOVER = 4;
LOAD_TAB_NORM = 5;
LOAD_TAB_HOVER = 6;
SAVE_TAB_NORM = 7;
SAVE_TAB_HOVER = 8;
TAB_NORM_1 = 9;
TAB_HOVER_1 = 10;
TAB_NORM_2 = 11;
TAB_HOVER_2 = 12;
TAB_NORM_3 = 13;
TAB_HOVER_3 = 14;
TAB_NORM_4 = 15;
TAB_HOVER_4 = 16;
TAB_NORM_5 = 17;
TAB_HOVER_5 = 18;
LOC_ICON_NORM = 19;
LOC_ICON_HOVER = 20;
LOC_EXIT_NORM = 21;
LOC_EXIT_HOVER = 22;
LOC_MAP = 23;
LOC_NAV = 24;
LOC_BORD_TOP = 25;
LOC_BORD_BOTTOM = 26;
LOC_BORD_LEFT = 27;
LOC_BORD_RIGHT = 28;
LOC_BOX_TOP = 29;
LOC_BOX_LEFT = 30;
LOC_LABEL = 31;
TAB_HINT = 32;
TAB_NORM_0 = 33;
TAB_HOVER_0 = 34;

var
frmMain: TForm;
time: TTimer;

tImages: Array[0..IMG_COUNT - 1] of TImage;

frmBitmaps: Array [0..BITMAP_COUNT - 1] of Integer;

isActiveImage: Array[0..IMG_COUNT - 1] of Boolean;
isLeftTab: Array[IMG_TAB_NORM_1..IMG_TAB_NORM_5] of Boolean;

MapDragStartX, MapDragStartY: Integer;

panels: array [IMG_TAB_NORM_1..IMG_TAB_NORM_1 + PANEL_NUM - 1] of TPanel;





var //Panel 2
UserList: TCheckListBox;
User, Pass: TEdit;
Button1,Button2: TButton;
Label_2, label2_2: TLabel;
var //Panel 3
ComboBox_3: TComboBox;
Add_3, Delete_3: TButton;
CheckListBox_3: TCheckListBox;
var //Panel 4
ComboBox_4: TComboBox;
Add_4, Delete_4: TButton;
CheckListBox_4: TCheckListBox;
var //Panel 5
Label_5, Label2_5: TLabel;
ComboBox_5: TComboBox;
Add_5, Delete_5: TButton;
Edit_5, Edit2_5: TEdit;


procedure OutsideBox(l,t,r,b, obj: integer);
begin
if tImages[obj].Left > l then
tImages[obj].Left := l;
if tImages[obj].Top > t then
tImages[obj].Top := t;
if tImages[obj].Left < r then
tImages[obj].Left := r;
if tImages[obj].Top < b then
tImages[obj].Top := b;
end;

procedure DDrawBitmap(Bmp: Longint; dest: TCanvas; x,y: integer);
begin
{$IFDEF SIMBA}
DrawBitmap(Bmp,dest,x,y);
{$ELSE}
SafeDrawBitmap(Bmp,dest,x,y);
{$ENDIF}
end;

function IsMouseButtonDow(yes: LongInt): boolean;
begin
{$IFDEF SIMBA}
result := IsMouseButtonDown(yes);
{$ELSE}
if yes = 1 then
result := IsMouseButtonDown(True)
else
result := IsMouseButtonDown(False);
{$ENDIF}
end;

procedure OnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
BoundL, BoundT: Extended;
begin
case sender of
tImages[IMG_LOC_MAP]:
begin
MapDragStartX := x;
MapDragStartY := y;
end;
tImages[IMG_LOC_NAV]:
begin
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x + (x - left), {T} y + (y - top), {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

OutsideBox(0,0,-345, -354, IMG_LOC_MAP);
end;
end;
end;

procedure IntroVisible(Visible: Boolean);
begin
// Show/hide components on the introduction tab
if (not Visible) then
begin
tImages[IMG_LOC_ICON_NORM].Visible := False;
tImages[IMG_LOC_LABEL].Visible := False;
tImages[IMG_TAB_HINT].Visible := False;
end else begin
tImages[IMG_LOC_ICON_NORM].Visible := True;
tImages[IMG_LOC_LABEL].Visible := True;
tImages[IMG_TAB_HINT].Visible := True;
end;
end;

const
MAX_MOVE = 315;

var
accel, move, senderTab, pan: integer;
cons: array [IMG_TAB_NORM_1..IMG_TAB_NORM_1 + PANEL_NUM - 1] of integer;
onLeft: Boolean;

procedure TimerTabClick(Sender: TObject);
var
i, e, d, hi, lo: Integer;
begin
accel := accel + 2;
move := move + accel;

if (senderTab = IMG_TAB_NORM_0) then
begin
for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_5 do
begin
if (not isLeftTab[i]) then
Continue;

tImages[i].Left := tImages[i].Left + accel;

if (move >= MAX_MOVE) then
begin
isLeftTab[i] := False;
time.Enabled := False;
tImages[i].Left := tImages[i].Left - 5;
IntroVisible(True);
end;
end;
end else
begin
if (onLeft) then
for i := senderTab to IMG_TAB_NORM_5 do
begin
if (i = senderTab) or (not isLeftTab[i]) then
Continue;

tImages[i].Left := tImages[i].Left + accel;

if (move >= MAX_MOVE) then
begin
isLeftTab[i] := False;
time.Enabled := False;
tImages[i].Left := tImages[i].Left - 5;
end;

Writeln(BoolToStr(isLeftTab[i]));
end
else
for i := senderTab downto IMG_TAB_NORM_1 do
begin
if (isLeftTab[i]) then
Continue;

tImages[i].Left := tImages[i].Left - accel;

if (move >= MAX_MOVE) then
begin
isLeftTab[i] := True;
time.Enabled := False;
tImages[i].Left := tImages[i].Left + 5;
end;

IntroVisible(False);
end;
end;

for i := IMG_TAB_NORM_1 to high(panels) do
begin
panels[i].left := tImages[i].left + tImages[i].width + 2
if i <> high(Panels) then
panels[i].width := tImages[i + 1].left - panels[i].left - 2
else
panels[i].width := frmMain.width - panels[i].left - 10;
end;
end;

procedure TabClick(Sender: TObject);
var
i: integer;
begin
if not time.ENABLED then
begin
accel := 0;
move := 0;
time.enabled := true;
pan := senderTab;

if (Sender = tImages[IMG_TAB_NORM_0]) then
senderTab := IMG_TAB_NORM_0;

for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_5 do
if (Sender = tImages[i]) then
begin
senderTab := i;
if (isLeftTab[senderTab]) then
onLeft := True
else
onLeft := False;
end;
end;
end;

procedure LocViewer(Sender: TObject);
var
i: Integer;
am: TintegerArray;
tru: boolean;
begin
am := [IMG_LOC_ICON_NORM, IMG_TAB_HINT, IMG_LOC_LABEL, IMG_TAB_NORM_0];

case Sender of
tImages[IMG_LOC_ICON_NORM]: begin
tru := true;
for i := low(panels) to high(panels) do
panels[i].visible := false;
end;
tImages[IMG_LOC_EXIT_NORM]: begin
tru := false;
//for i := low(panels) to high(panels) do
//panels[i].visible := true;
end;
end;

for i := IMG_LOC_EXIT_NORM to IMG_LOC_BOX_BOTTOM do
tImages[i].Visible := tru;

for i := 0 to high(am) do
tImages[am[i]].Visible := not tru;
end;

procedure Clicked(Sender: TObject);
var
i: Integer;
begin
for i := 0 to BITMAP_COUNT - 1 do
FreeBitmap(frmBitmaps[i]);
frmMain.ModalResult := mrOk;
end;

procedure MouseMoved(Sender: TObject; Shift: TShiftState; x, y: Integer);
var
hi, i, bmp, xdif, ydif, h: Integer;
BoundL, BoundT: Extended;
imgSwap, bmpArr, imgArr: Array of Integer;
begin
bmpArr := [ X_NORM, Q_NORM, LOAD_TAB_NORM,
SAVE_TAB_NORM, TAB_NORM_1, TAB_NORM_2,
TAB_NORM_3, TAB_NORM_4, TAB_NORM_5, LOC_ICON_NORM, LOC_EXIT_NORM,
TAB_NORM_0 ];

imgArr := [ IMG_X_NORM, IMG_Q_NORM, IMG_LOAD_TAB_NORM,
IMG_SAVE_TAB_NORM, IMG_TAB_NORM_1, IMG_TAB_NORM_2,
IMG_TAB_NORM_3, IMG_TAB_NORM_4, IMG_TAB_NORM_5, IMG_LOC_ICON_NORM,
IMG_LOC_EXIT_NORM, IMG_TAB_NORM_0 ];

hi := High(bmpArr);
case Sender of
tImages[IMG_BGND], tImages[IMG_LOC_MAP]:
begin
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;

bmp := frmBitmaps[bmpArr[i]];
DDrawBitmap(bmp,tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;
end;
for h := 0 to hi do
case Sender of
tImages[imgArr[h]]:
begin
imgSwap := [imgArr[h], frmBitmaps[bmpArr[h] + 1]];
if not (isActiveImage[imgSwap[0]]) then
begin
DDrawBitmap(imgSwap[1],tImages[imgSwap[0]].Canvas,0,0);
isActiveImage[imgSwap[0]] := True;
for i := 0 to hi do
begin
if (Sender = tImages[imgArr[i]]) then
Continue;

if (not isActiveImage[imgArr[i]]) then
Continue;

if (i = imgSwap[0] - 1) then
Continue;

if imgSwap[0] = IMG_LOC_EXIT_NORM then
if (i = imgSwap[0]) then
Continue;

if imgSwap[0] = IMG_LOC_ICON_NORM then
if (i = imgSwap[0] - 10) then
Continue;

bmp := frmBitmaps[bmpArr[i]];
DDrawBitmap(bmp, tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;
end;
end;
case sender of
tImages[IMG_LOC_MAP]:
begin
if not IsMouseButtonDow(1) then exit;
xdif := x - MapDragStartX;
ydif := y - MapDragStartY;
tImages[IMG_LOC_MAP].Left := tImages[IMG_LOC_MAP].Left + xdif;
tImages[IMG_LOC_MAP].Top := tImages[IMG_LOC_MAP].Top + ydif;

OutsideBox(0,0,-854, -765, IMG_LOC_MAP);

BoundL := -tImages[IMG_LOC_MAP].Left / 7.234 + 376;
BoundT := -tImages[IMG_LOC_MAP].Top / 7.234 + 216;


with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} Round(BoundL), {T} Round(BoundT), {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);
end;
tImages[IMG_LOC_NAV]:
begin
if not IsMouseButtonDow(1) then exit;
GetMousePos(x, y);
with tImages[IMG_LOC_BOX_TOP] do
SetBounds({L} x - 55 - 100, {T} y - 40 - 100, {W} 83, {H} 1);

OutsideBox(494,322,376, 216, IMG_LOC_BOX_TOP);

with tImages[IMG_LOC_BOX_LEFT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_RIGHT] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left + 83, {T} tImages[IMG_LOC_BOX_TOP].Top + 1, {W} 1, {H} 55);
with tImages[IMG_LOC_BOX_BOTTOM] do
SetBounds({L} tImages[IMG_LOC_BOX_TOP].Left, {T} tImages[IMG_LOC_BOX_TOP].Top + 55, {W} 83, {H} 1);

BoundL := -(x - 155 - 376) * 7.234;
BoundT := -(y - 140 - 216) * 7.234;

tImages[IMG_LOC_MAP].Left := Round(BoundL);
tImages[IMG_LOC_MAP].Top := Round(BoundT);

OutsideBox(0, 0, -854, -765, IMG_LOC_MAP);
end;
end;
end;

procedure OnClickEvents(Sender: TObject);
var
i, t: integer;
begin
for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_5 do
if (isLeftTab[i]) then
Inc(t);

for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_5 do
case Sender of
tImages[i]:
begin
if (isLeftTab[i]) then
if (t <= (i - (IMG_TAB_NORM_5 - IMG_TAB_NORM_1))) then
Exit;

TabClick(Sender);
end;
end;

case Sender of
tImages[IMG_X_NORM]: Clicked(Sender);
tImages[IMG_LOC_ICON_NORM], tImages[IMG_LOC_EXIT_NORM]: LocViewer(Sender);

tImages[IMG_TAB_NORM_0]:
begin
if (t <= 0) then
Exit;

TabClick(Sender);
end;
end;
end;

procedure Panel2Clicks(Sender: TObject);
var sel: integer;
begin
case sender of
Button1: begin
UserList.Items.Append(User.Text + ' (' + Pass.Text + ')');
combobox_3.items.append(User.Text);
combobox_4.items.append(User.Text);
UserList.Checked[UserList.items.Count - 1] := true;
UserList.ItemIndex := UserList.items.Count - 1;
User.Text := '';
Pass.Text := '';
end;
Button2: begin
if UserList.ItemIndex >= 0 then
sel := UserList.ItemIndex;
UserList.Items.Delete(sel);
combobox_3.Items.Delete(sel);
combobox_4.Items.Delete(sel);
if sel = 0 then
sel := 1;
UserList.ItemIndex := sel - 1;
User.Text := '';
Pass.Text := '';
end;
UserList: begin
User.Text := UserList.items.strings[UserList.ItemIndex];
Pass.Text := UserList.items.strings[UserList.ItemIndex];
end;
end;
end;

procedure Panel3Clicks(Sender: TObject);
begin
case sender of
Add_3: begin
if Combobox_3.ITEMINDEX > 0 then
combobox_3.ItemIndex := combobox_3.ItemIndex - 1;
end;
Combobox_3: begin
end;
Delete_3: begin
if Combobox_3.ITEMINDEX < Combobox_3.ITEMS.Count then
combobox_3.ItemIndex := combobox_3.ItemIndex + 1;
end;
end;
end;

procedure Panel4Clicks(Sender: TObject);
begin
case sender of
Add_4: begin
if Combobox_4.ITEMINDEX > 0 then
combobox_4.ItemIndex := combobox_4.ItemIndex - 1;
end;
Combobox_4: begin
end;
Delete_4: begin
if Combobox_4.ITEMINDEX < Combobox_4.ITEMS.Count then
combobox_4.ItemIndex := combobox_4.ItemIndex + 1;
end;
end;
end;

procedure Panel2Clic(Sender: TObject; Index: Integer);
begin

end;

procedure InitForm;
var
i, pan: Integer;
consts: TintegerArray;
bmpArr: TStringArray;
xy: TPointArray;
visibl: array of boolean;
wh: TPoint;
begin
bmpArr := ['BGND','X_NORM','X_HOVER','Q_NORM','Q_HOVER','LOAD_TAB_NORM','LOAD_TAB_HOVER','SAVE_TAB_NORM','SAVE_TAB_HOVER','TAB_NORM_1','TAB_HOVER_1','TAB_NORM_2','TAB_HOVER_2','TAB_NORM_3','TAB_HOVER_3','TAB_NORM_4','TAB_HOVER_4','TAB_NORM_5','TAB_HOVER_5','LOC_ICON_NORM','LOC_ICON_HOVER','LOC_EXIT_NORM','LOC_EXIT_HOVER','LOC_MAP','LOC_NAV','LOC_BORD_TOP','LOC_BORD_BOTTOM','LOC_BORD_LEFT','LOC_BORD_RIGHT','LOC_BOX_TOP','LOC_BOX_LEFT','LOC_LABEL','TAB_HINT','TAB_NORM_0','TAB_HOVER_0'];
for i := 0 to High(frmBitmaps) do
frmBitmaps[i] := LoadBitmap(ScriptPath + 'Bitmaps\' + bmpArr[i] + '.png');

frmMain := TForm.Create(nil);
frmMain.SetBounds({L} 100, {T} 100, {W} 600, {H} 400);
frmMain.Position := poScreenCenter;
frmMain.BorderStyle := bsNone;

time := TTimer.Create(frmMain);
with time do
begin
ONTIMER := @TimerTabClick;
INTERVAL := 10;
ENABLED := false;
end;

xy := [Point(0,0), Point(575,7), Point(557,7), Point(7,69), Point(81,69), Point(386, 100), Point(427,100), Point(468,100), Point(509,100), Point(550,100), Point(165,220), Point(475,7), Point(-300,0), Point(369,209), Point(0,0), Point(0,393), Point(0,7), Point(593,7), Point(Round( 300 / 7.234 + 376), 216), Point(Round( 300 / 7.234 + 376), 216 + 1), Point(Round( 300 / 7.234 + 376) + 83, 216 + 1), Point(Round( 300 / 7.234 + 376), 216 + 1 + 54), Point(142,262), Point(100,379), Point(8, 222) ];
SetArrayLength(visibl, GetArrayLength(xy));
visibl := [true, true, true, true, true, true, true, true, true, true, True, false, false, false, false, false, false, false, false, false, false, false, true, true, True ];
consts := [BGND, X_NORM, Q_NORM, LOAD_TAB_NORM,SAVE_TAB_NORM,TAB_NORM_1, TAB_NORM_2, TAB_NORM_3, TAB_NORM_4, TAB_NORM_5, LOC_ICON_NORM, LOC_EXIT_NORM, LOC_MAP, LOC_NAV, LOC_BORD_TOP, LOC_BORD_BOTTOM, LOC_BORD_LEFT, LOC_BORD_RIGHT, LOC_BOX_TOP, LOC_BOX_LEFT, LOC_BOX_LEFT, LOC_BOX_TOP, LOC_LABEL, TAB_HINT, TAB_NORM_0 ];

for i := low(panels) to high(panels) do
begin
panels[i] := TPanel.Create(frmMain);
panels[i].parent := frmMain;
GetBitmapSize(frmBitmaps[consts[i]], wh.x, wh.y);
panels[i].SetBounds(xy[i].x + wh.x, xy[i].y, 0, wh.y);
panels[i].BEVELWIDTH := 0;
// panels[i].COLOR := 1909544;
// panels[i].visible := false;
end;

for i := 0 to IMG_COUNT - 1 do
begin
tImages[i] := TImage.Create(frmMain)
with tImages[i] do
begin
Parent := frmMain;
GetBitmapSize(frmBitmaps[consts[i]], wh.x, wh.y);
SetBounds(xy[i].x, xy[i].y, wh.x, wh.y);
OnMouseMove := @MouseMoved;
ONMOUSEDOWN := @OnMouseDown;
OnClick := @OnClickEvents;
isActiveImage[i] := False;
visible := Visibl[i];
end;
DDrawBitmap(frmBitmaps[consts[i]], tImages[i].canvas, 0, 0);
end;

pan := IMG_TAB_NORM_1;

UserList := TCheckListBox.Create(panels[pan]);
UserList.Parent := panels[pan];
UserList.SetBounds(24,40,225,241);
//UserList.OnItemClick := @Panel2Clic;

Label_2 := TLabel.Create(panels[pan]);
Label_2.Parent := panels[pan];
Label_2.Setbounds(260,50,50,13);
Label_2.Caption := 'Username';

User := TEdit.Create(panels[pan]);
User.Parent := panels[pan];
User.SetBounds(260,Label_2.top + Label_2.height + 4,105,21);

Label2_2 := TLabel.Create(panels[pan]);
Label2_2.Parent := panels[pan];
Label2_2.Setbounds(260,User.top + User.height + 10,32,13);
Label2_2.Caption := 'Password';

Pass := TEdit.Create(panels[pan]);
Pass.Parent := panels[pan];
Pass.SetBounds(260,Label2_2.top + Label2_2.height + 4,105,21);

Button1 := TButton.Create(panels[pan]);
Button1.Parent := panels[pan];
Button1.Setbounds(24,8,107,25);
Button1.Caption := 'Add Player';
Button1.ONCLICK := @Panel2Clicks;

Button2 := TButton.Create(panels[pan]);
Button2.Parent := panels[pan];
Button2.SetBounds(144,8,107,25);
Button2.Caption := 'Remove Player';
Button2.OnClick := @Panel2Clicks;





pan := IMG_TAB_NORM_2;

Add_3 := TButton.Create(panels[pan]);
Add_3.Parent := panels[pan];
Add_3.SetBounds(5,5,73,25);
Add_3.Caption := 'Previous';
Add_3.OnClick := @Panel3Clicks;

ComboBox_3 := TComboBox.Create(panels[pan]);
ComboBox_3.Parent := panels[pan];
ComboBox_3.SetBounds(add_3.left + add_3.width + 5,5,105,21);
ComboBox_3.Text := 'Player';
ComboBox_3.OnClick := @Panel3Clicks;

Delete_3 := TButton.Create(panels[pan]);
Delete_3.Parent := panels[pan];
Delete_3.SetBounds(ComboBox_3.left + ComboBox_3.width + 5,5,75,25);
Delete_3.Caption := 'Next';
Delete_3.OnClick := @Panel3Clicks;

CheckListBox_3 := TCheckListBox.Create(panels[pan]);
CheckListBox_3.Parent := panels[pan];
CheckListBox_3.SetBounds(8,40,365,245);
CheckListBox_3.Items.Append('Woodcutting');
CheckListBox_3.Items.Append('---Varrok East');
CheckListBox_3.Items.Append('---Draynor');
CheckListBox_3.Items.Append('---Port Sarim');
CheckListBox_3.Items.Append('Mining');
CheckListBox_3.Items.Append('---Lumbridge Swamp');
CheckListBox_3.Items.Append('------East');
CheckListBox_3.Items.Append('------West');




pan := IMG_TAB_NORM_3;

Add_4 := TButton.Create(panels[pan]);
Add_4.Parent := panels[pan];
Add_4.SetBounds(5,5,73,25);
Add_4.Caption := 'Previous';
Add_4.OnClick := @Panel4Clicks;

ComboBox_4 := TComboBox.Create(panels[pan]);
ComboBox_4.Parent := panels[pan];
ComboBox_4.SetBounds(add_4.left + add_4.width + 5,5,105,21);
ComboBox_4.Text := 'Player';
ComboBox_4.OnClick := @Panel4Clicks;

Delete_4 := TButton.Create(panels[pan]);
Delete_4.Parent := panels[pan];
Delete_4.SetBounds(ComboBox_4.left + ComboBox_4.width + 5,5,75,25);
Delete_4.Caption := 'Next';
Delete_4.OnClick := @Panel4Clicks;

CheckListBox_4 := TCheckListBox.Create(panels[pan]);
CheckListBox_4.Parent := panels[pan];
CheckListBox_4.SetBounds(8,40,365,245);




pan := IMG_TAB_NORM_4;

Add_5 := TButton.Create(panels[pan]);
Add_5.Parent := panels[pan];
Add_5.SetBounds(5,5,73,25);
Add_5.Caption := 'Previous';

ComboBox_5 := TComboBox.Create(panels[pan]);
ComboBox_5.Parent := panels[pan];
ComboBox_5.SetBounds(add_5.left + add_5.width + 5,5,105,21);
ComboBox_5.Text := 'Player';

Delete_5 := TButton.Create(panels[pan]);
Delete_5.Parent := panels[pan];
Delete_5.SetBounds(ComboBox_5.left + ComboBox_5.width + 5,5,75,25);
Delete_5.Caption := 'Next';

Label_5 := TLabel.Create(panels[pan]);
with Label_5 do
begin
Parent := panels[pan];
Setbounds(5,Add_5.top + Add_5.height + 10,32,13);
Caption := 'Loads Before Switching Players:';
end;
Edit_5 := TEdit.Create(panels[pan]);
with Edit_5 do
begin
Parent := panels[pan];
SetBounds(5,Label_5.top + Label_5.height + 4,150,13);
end;
Label2_5 := TLabel.Create(panels[pan]);
with Label2_5 do
begin
Parent := panels[pan];
Setbounds(5,Edit_5.top + Edit_5.height + 15,32,13);
Caption := 'Total Loads:';
end;
Edit2_5 := TEdit.Create(panels[pan]);
with Edit2_5 do
begin
Parent := panels[pan];
SetBounds(5,Label2_5.top + Label2_5.height + 4,150,13);
end;






//isLeftTab[IMG_TAB_NORM_1] := true;
//panels[IMG_TAB_NORM_1].width := 377;
tImages[11].BringToFront;
//senderTab := IMG_TAB_NORM_1;
end;

procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;

procedure ShowFormModal;
begin
frmMain.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;

begin
//ClearDebug;
try
SafeInitForm;
SafeShowFormModal;
finally
time.ENABLED := false;
time.Free;
frmMain.Free;
except
Writeln(ExceptionToString(ExceptionType, ExceptionParam));
end;
end.
The only problems with the form now that I can see, would be needing to add the panels to the onmousemove events so that the tabs go off the hover versions when you move the mouse to a panel. The problem would be that I dont really know how that whole thing works very well. So the easiest thing I can think of is doing like i did a while ago. Adding an image over the entire panel, except this time making it invisible, and then adding it to the list inside the onmousemove events. I havent the time now, but i can try it later if you dont.

Coh3n

2010-11-22 13:02:09

Looks good. Any idea why the acceleration from left to right is so slow on most of the tabs?

Dan Cardin

2010-11-22 15:20:53

It doesnt seem slow at all for me. Problem with your computer?

Coh3n

2010-11-22 15:40:16

From: Dan Cardin
It doesnt seem slow at all for me. Problem with your computer?

Weird, must have been just the one time. I tried again and it's working. Lol.

Nava2

2010-11-22 16:56:38

From: Coh3n
Weird, must have been just the one time. I tried again and it's working. Lol.


That screams memory leak to me..

Coh3n

2010-11-22 19:39:22

From: Nava2
That screams memory leak to me..

Not sure how though. I opened it, it was slow. I closed it and tried again, it was fast. I didn't do anything different.

Dan Cardin

2010-11-22 21:22:01

I'm not really sure how it could be a memory leak in this kind of thing anyway. The number of images is static and they're all loaded at the beginning.

Coh3n

2010-11-29 01:41:13

Updated a little. I made the background of each panel an image rather than a solid color. Can't really tell the difference, but I wanted to see if I could do it so I may as well leave it now. I also made the first tab look a little better (sizes and colors mostly).

Dan Cardin

2010-11-29 07:05:21

are you able to add them to the onmouseevent thing so that the hover images go away when you mouse over them? With just the panel sometimes it doesn't unhover, but now that there's an image it should be able to work.

Coh3n

2010-11-29 19:21:37

From: Dan Cardin
are you able to add them to the onmouseevent thing so that the hover images go away when you mouse over them? With just the panel sometimes it doesn't unhover, but now that there's an image it should be able to work.

Do we want that though? I mean, there should be some sort of indicator as to which tab is the active one, right?

E: I committed a sort-of fix. It's not 100% perfect, but it'll work for now, and it doesn't cause any errors.

Dan Cardin

2010-11-29 20:42:52

The mouse moving thing isnt working with it. I dunno why. And you don't want this because the currently selected tab is not necessarily the one being hovered. It could be easier to check the other way around, like use hover if the mouse is on the same place as the object rather than the way it is now, but that would need a timer and wouldn't be as efficient cuz the form at rest would be doing stuff still. It would however, probably make things a lot simpler. Oh well.

Coh3n

2010-11-30 02:47:00

From: Dan Cardin
The mouse moving thing isnt working with it. I dunno why. And you don't want this because the currently selected tab is not necessarily the one being hovered. It could be easier to check the other way around, like use hover if the mouse is on the same place as the object rather than the way it is now, but that would need a timer and wouldn't be as efficient cuz the form at rest would be doing stuff still. It would however, probably make things a lot simpler. Oh well.

The only time it doesn't work for me is if I move the mouse from the tab to the panel really fast, and even then it usually works.

E: I've worked on it a little, tell me what you think. I just made the tabs look a little nicer and more orgainzed. Also, I changed the color of the TEdits in the first tab just to see what it looks like. I don't really like it all being plain white, but I haven't been able to figure out how to change the color of the TListBox or TButtons. Plain white isn't bad, but if we can make it blend in more that would be great.

E2: I think I fixed the mouse moving thing. You're right, it wasn't working. Now I'm almost positive it will only fail when you move the mouse really fast from the tab to a panel component (I'm haven't tried adding each component to the MouseMove event). Also, I tried adding Naum's form dragging method from this thread (GetPos, GetPosX, and GetPosY), but whenever I tried it Simba would crash. I can't figure out why, but I remember this method working a while ago when I tried it. E: Weird, it works when I don't include MSI. :unsure:

Also, I've made another test file that includes MSI and SRL so I'll be able to commit this to the MSI include so some of our users can test it out and give us feedback. :)

E3: I would really like to be able to drag the form around the screen. The way that works (when MSI isn't included) overrides the background's OnMouseMove event which means all the images are displayed wrong when moving the mouse over the background. If anyone knows another way to use the image to drag the form around the screen, please let us know!

Dan Cardin

2010-11-30 07:13:57

onmousedown, start a timer, getmousepos, move form, onmouseup end timer. best i can do for now, ill test and talk more later today.

EDIT: idk if you committed the fix, but it still doesnt fix the hover problem even going at relatively normal speeds. You could probably also commit taking out those Writelns in the tab animation thing. It is pretty flawless now.

also the timer would work. What exactly is the problem with having it as onmousemove?

I seem to remember RM or someone having a form that had custom edits and dropdowns and such. I'm sure that could be done. Most easily for the buttons at least. The only problem would then be the lists.

Loading and saving, attaching the form to MSI itself, and making the lists work are all priorities though, i would say.

EDIT: also it would benefit making the >> tab an actual tab because when you click to and away from that tab, the loc viewer just disappears and reappears. It would look better if it slide away like everything else. I failed when i tried making it a tab last time though :(.

Coh3n

2010-11-30 14:55:27

From: Dan Cardin
onmousedown, start a timer, getmousepos, move form, onmouseup end timer. best i can do for now, ill test and talk more later today.

EDIT: idk if you committed the fix, but it still doesnt fix the hover problem even going at relatively normal speeds. You could probably also commit taking out those Writelns in the tab animation thing. It is pretty flawless now.

also the timer would work. What exactly is the problem with having it as onmousemove?

I seem to remember RM or someone having a form that had custom edits and dropdowns and such. I'm sure that could be done. Most easily for the buttons at least. The only problem would then be the lists.

Loading and saving, attaching the form to MSI itself, and making the lists work are all priorities though, i would say.

I've committed what I have. I can't make the mouse moving any better. For me, it doesn't work like once every 10 times I try. I'm not really worried about that right now as it doesn't change the forms functionality.

The problem when OnMouseMove is that it's already pointed to an OnMouseMove procedure. I guess the GetPosX or whatever could just be added to that so it's all in one. But still, for whatever reason, when I include MSI and the form moving procedures, Simba crashes.

Yeah, I used custom buttoms in my Draynor Chopper form. Not edits or drop downs (I'm not sure how that would be done). If they need to stay the way they are, it's not the end of the world.

E: If you get some time, there's some small functionality things that can be done. The check boxes in the TListBoxes can only have one checked off at a time for both the scripts and locations (for now anyway). The save and load buttons need to work (not difficult at all). I was thinking about a second custom form (like in my Draynor form) that pops up if the user filled something out incorrectly.

If you want to see my form for an example it can be downloaded from here:

http://dcnb.googlecode.com/svn/trunk
Run the script file, not the form file and it works in both SCAR and Simba.

Coh3n

2010-12-05 04:06:37

I filled the scripts and locations list with MSI's scripts and locations. Anyone know if there's a way to show a bitmap of the script location (the same bitmap in the Supported Locations threads) when you double click (or right click) a CheckBoxMenu item?

Dan Cardin

2010-12-05 11:15:16

I would just have a bitmap pop up that says you are doing it wrong and that clickin on the bitmap will make it go away. It would just need to look like it was seperate from the form itself, kinda like Fx's new popup things in 4.0. If not, i dont think its a big deal. You could iirc make a "form" pop up. I forget how, but its similar to Readln, without needing to answer anything.

Coh3n

2010-12-17 18:42:14

From: Dan Cardin
I would just have a bitmap pop up that says you are doing it wrong and that clickin on the bitmap will make it go away. It would just need to look like it was seperate from the form itself, kinda like Fx's new popup things in 4.0. If not, i dont think its a big deal. You could iirc make a "form" pop up. I forget how, but its similar to Readln, without needing to answer anything.


ShowMessage('This will show in the form popup');

That would be the easiest and probably is what I'll do, it just doesn't fit with the rest of the form. :p

E: Did the 4th panel and started on the 5th.

I made the 5th panel for script setup so there's lots of room for new additions to TScriptSetup. I'm thinking we'll have another list (like the player list, with next and previous buttons) for scripts and then display different components depending the type of script chosen (i.e. different for each skill).

E: All panels except the last one are done + saving and loading is finished.

Dan Cardin

2010-12-17 19:43:29

gah, i can't run it anymore :(. I dont have everything else set up :(.

Coh3n

2010-12-18 01:54:28

From: Dan Cardin
gah, i can't run it anymore :(. I dont have everything else set up :(.

If you just download MSI to your includes folder, it will work.

SVN: http://www.villavu.com/repositories/msi

Dan Cardin

2010-12-18 14:07:18

ah, i thought you meant all functionality was there. if simba sports save and load dialogs, i think it would make more sense to use those for loading and saving players than just doing so automatically.

Do you plan on having anything else on the locviewer tab? If not i still don't get why it has its own tab. Seems like it would make so much more sense to put it up top out of tab. I also just thought it might make more sense to take it out of the form. If i am thinking correctly, it would make sense to put it in a seperate file. Give it a mousedrag function, then have it be a seperate utility. the function would return a bitmap that you display on the form. I think it would make the whole form less complicated and long. Understand what i mean?

Coh3n

2010-12-18 14:30:57

From: Dan Cardin
ah, i thought you meant all functionality was there. if simba sports save and load dialogs, i think it would make more sense to use those for loading and saving players than just doing so automatically.

Do you plan on having anything else on the locviewer tab? If not i still don't get why it has its own tab. Seems like it would make so much more sense to put it up top out of tab. I also just thought it might make more sense to take it out of the form. If i am thinking correctly, it would make sense to put it in a seperate file. Give it a mousedrag function, then have it be a seperate utility. the function would return a bitmap that you display on the form. I think it would make the whole form less complicated and long. Understand what i mean?

There's is nothing organized about the code. >.< Due to having three different people write it, it's just a big mess. There's about 100 things that aren't used. I plan on putting the script setup information on the location viewer tab, and getting rid of the location viewer altogether as it doesn't even work properly. The setup consts in RunMe.simba will probably have to be made into variables and will appear on the location viewer tab. I'll probably just make an array (MSI_SetupVariables).

DEBUG_SMART = True; // Debugs things onto SMART (may cause lag)
BREAK_TIME = 15; // Single player only - how long to break for (in minutes)
SAVE_DEBUG = True; // Save's the debug box text to a file
ENABLE_REMOTE = True; // Do you want to enable the Player Remote?
LEVEL_TO_DEBUG = 10; // The lower the number, the less the script will debug
HUMAN_BREAKING = True; // Take more human like breaks
SWITCH_WORLDS = False; // Switch worlds when switching players or after breaks
ANTIBAN_MIN_WAIT = 14000; // Minimum time to wait between antibans
RANDOMS_MIN_WAIT = 10000; // Minimum time to wait between randoms checks

WORLD_SMART = 152;

STATS_ID = ''; // Temporary stats ID (2 digit number)
STATS_PASS = ''; // Temporary stats password

I'm really not worried about the organization of the form and getting rid of things that aren't used. I'm just worried about getting it done and working. If we feel that it needs to be cleaned up later, then we can, but for now, I just want it to work. :p

Oh, and I don't know what you mean about the save/load thing. Right now it saves using INI functions when the save button is pressed. Same with loading.

E: Committed a bunch more stuff. See SVN log for details.

Dan Cardin

2010-12-18 18:43:07

The problem is that the form is going to get so unwieldy that it will be impossible to change without screwing everything up. I just tried to take out the loc viewer and now it wont compile. (one of the reasons i didn't want everything being based off of constants.)

And to get it to work, hopefully we could just use the earliest version of it. That's why I wanted to make it a separate entity from the form. If we did all the logic for the loc viewer in it's own module, you could just send it coordinates for mouse dragging. Then it would logic everything out, and return a bitmap to be displayed. Hopefully it wouldn't be too much work, but i would leave it until the form is done. Even then I would wait because I think that RM's thread where he wanted all the scripts being marked on the map could be done programatically inside the loc viewer to make it a lot more useful.

Anyways, the form code is too long now as it is. If i can get the loc viewer out, im gonna try to put the previous/next/name things into arrays. You could then create it all at once.

EDIT: all the edits and labels and such should be in arrays too. but most people don't like doing it that way because then you cant use like…"password" for the name, you'd need edit[5]. but it makes everything a lot lot shorter.

EDIT: i dont know if there is a file with all the constants/vars necessary in it, but it would be a better if you could not load msi and srl and smart before the form. ideally it would load the form, then everything else would only come afterward.

EDIT:
  for i := low(panels) to high(panels) do
begin
panels[i] := TPanel.Create(form_Main);
panels[i].parent := form_Main;
GetBitmapSize(frmBitmaps[consts[i]], wh.x, wh.y);
panels[i].SetBounds(xy[i].x + wh.x, xy[i].y, 0, wh.y);
panels[i].BEVELWIDTH := 0;

bgndPanel := TImage.Create(panels[i]);
bgndPanel.Parent := panels[i];
bgndPanel.Visible := True;
GetBitmapSize(frmBitmaps[BGND_PANEL], a, b);
bgndPanel.SetBounds(0, 0, a, b);
DrawBitmap(frmBitmaps[BGND_PANEL], bgndPanel.Canvas, 0, 0);
end;
is it just me or will that just create bgndpanel on whichever tab is last and that's it?

EDIT: same form without the loc viewer.
const
DEBUG_SMART = True; // Debugs things onto SMART (may cause lag)
BREAK_TIME = 15; // Single player only - how long to break for (in minutes)
SAVE_DEBUG = True; // Save's the debug box text to a file
ENABLE_REMOTE = True; // Do you want to enable the Player Remote?
LEVEL_TO_DEBUG = 10; // The lower the number, the less the script will debug
HUMAN_BREAKING = True; // Take more human like breaks
SWITCH_WORLDS = False; // Switch worlds when switching players or after breaks
ANTIBAN_MIN_WAIT = 14000; // Minimum time to wait between antibans
RANDOMS_MIN_WAIT = 10000;

WORLD_SMART = 152;

STATS_ID = ''; // Temporary stats ID (2 digit number)
STATS_PASS = ''; // Temporary stats password

{$i MSI/MSI/Core/Setup.simba}

const
IMG_COUNT = 11;
// Used in form_Main
IMG_BGND = 0;
IMG_X_NORM = 1;
IMG_Q_NORM = 2;
IMG_LOAD_TAB_NORM = 3;
IMG_SAVE_TAB_NORM = 4;
IMG_TAB_NORM_1 = 5;
IMG_TAB_NORM_2 = 6;
IMG_TAB_NORM_3 = 7;
IMG_TAB_NORM_4 = 8;
IMG_TAB_NORM_5 = 9;
IMG_TAB_NORM_0 = 10;

PANEL_NUM = 5;
// Used in Panel 1

// Used in Panel 2

// Used in Panel 3

// Used in Panel 4

BITMAP_COUNT = 22;
BGND = 0;
X_NORM = 1;
X_HOVER = 2;
Q_NORM = 3;
Q_HOVER = 4;
LOAD_TAB_NORM = 5;
LOAD_TAB_HOVER = 6;
SAVE_TAB_NORM = 7;
SAVE_TAB_HOVER = 8;
TAB_NORM_1 = 9;
TAB_HOVER_1 = 10;
TAB_NORM_2 = 11;
TAB_HOVER_2 = 12;
TAB_NORM_3 = 13;
TAB_HOVER_3 = 14;
TAB_NORM_4 = 15;
TAB_HOVER_4 = 16;
TAB_NORM_5 = 17;
TAB_HOVER_5 = 18;
TAB_NORM_0 = 19;
TAB_HOVER_0 = 20;
BGND_PANEL = 21;

var
form_Main: TForm;
time: TTimer;

tImages: Array[0..IMG_COUNT - 1] of TImage;

frmBitmaps: Array [0..BITMAP_COUNT - 1] of Integer;

isActiveImage: Array[0..IMG_COUNT - 1] of Boolean;
isLeftTab: Array[IMG_TAB_NORM_1..IMG_TAB_NORM_5] of Boolean;

panels: array [IMG_TAB_NORM_1..IMG_TAB_NORM_1 + PANEL_NUM - 1] of TPanel;

var
bgndPanel: TImage;
a, b: Integer;
pBoxIndex: Integer;


{var // Intro Panel
intro_Edits: array[0..SETUP_VARS_LENGTH - 1] of TEdit;
intro_Labels: array[0..SETUP_VARS_LENGTH - 1] of TLabel; }

var //Panel 2
UserList: TCheckListBox;
edit_User, edit_Pass, edit_Pin: TEdit;
btn_AddPlayer, btn_DeletePlayer: TButton;
Label_2, label2_2, inst_P2, pin_P2, label_Member: TLabel;
comboBox_Member: TComboBox;

var //Panel 3
ComboBox_3: TComboBox;
Add_3, Delete_3: TButton;
CheckListBox_3: TCheckListBox;
inst_P3: TLabel;

var //Panel 4
ComboBox_4: TComboBox;
Add_4, Delete_4: TButton;
CheckListBox_4: TCheckListBox;
inst_P4: TLabel;

var //Panel 5
inst_P5, timeTotal, timeBreak, loadsBreak, loadsTotal: TLabel;
ComboBox_Player_5: TComboBox;
Add_5, Delete_5: TButton;
time_Total_5, time_Break_5, loads_Break_5, loads_Total_5: TEdit;

var //Panel 6
inst_P6: TLabel;
ComboBox_Player_6, ComboBox_Script_6: TComboBox;
nextPlay, PrevPlayer, nScript, pScript: TButton;

// Get the current player index that is selected in a combo box
function GetPlayerIndex(s: string): Integer;
var
i: Integer;
begin
if (s = '') then
Exit;

for i := 0 to High(MSI_Players) do
if (Lowercase(MSI_Players[i].Name) = Lowercase(s)) then
begin
Result := i;
Exit;
end;
end;

(*
SCRIPT SETUP COMPONENTS & OTHER
===============================

Written by: Coh3n
*)

(**
* Used to for TScriptSetup for each player
*)
const
LIST_COUNT = 6;
LIST_ROCKS = 0;
LIST_TREES = 1;
LIST_FISHSPOTS = 2;
LIST_SPELLS = 3;
LIST_STAFFS = 4;
LIST_DROP = 5;

EDIT_COUNT = 6;
EDIT_LOADS = 0;
EDIT_TIME = 1;
EDIT_LEVEL = 2;
EDIT_EXCEPTIONS = 3;
EDIT_ALCH_SLOTS = 4;
EDIT_PRIORITY = 5;

var
script_ListTexts, script_EditTexts: TStringArray;
script_Lists: array[0..LIST_COUNT - 1] of TCheckListBox;
script_ListLabels: array[0..LIST_COUNT - 1] of TLabel;
script_Edits: array[0..EDIT_COUNT - 1] of TEdit;
script_EditLabels: array[0..EDIT_COUNT - 1] of TLabel;
script_StaffType: TComboBox;

procedure script_CreateComponents(PanelIndex: Integer);
var
i, j: Integer;
begin
// TCheckListBoxes
for i := 0 to High(script_Lists) do
begin
script_Lists[i] := TCheckListBox.Create(Panels[PanelIndex]);
with script_Lists[i] do
begin
Parent := Panels[PanelIndex];
Width := 140;
Height := 80;
Left := 20;
Top := 75;
Visible := False;

case i of
LIST_ROCKS:
begin
end;

LIST_TREES:
begin
end;

LIST_FISHSPOTS:
begin
end;

LIST_SPELLS:
begin
end;

LIST_STAFFS:
begin
Left := 20 + Width + 15;
end;

LIST_DROP:
begin
Left := 20 + Width + 15;

for i := 0 to High(MSI_Items) do
begin
if (MSI_Items[i].Name = '') then
Continue;

Items.Append(Capitalize(MSI_Items[i].Name));
end;
end;
end;
end;
end;

// TLabels
script_ListTexts := ['Rocks', 'Trees', 'Fishing Spots', 'Spells', 'Staffs', 'Don''t Drop/Bank'];
for i := 0 to High(script_ListLabels) do
begin
script_ListLabels[i] := TLabel.Create(Panels[PanelIndex]);
with script_ListLabels[i] do
begin
Parent := Panels[PanelIndex];
Height := 25;
Width := script_Lists[i].Width;
Left := script_Lists[i].Left;
Top := script_Lists[i].Top - (Height - 5);
Caption := script_ListTexts[i];
Font.Color := 2070783;
Visible := script_Lists[i].Visible;
end;
end;

// TEdits
for i := 0 to High(script_Edits) do
begin
script_Edits[i] := TEdit.Create(Panels[PanelIndex]);
with script_Edits[i] do
begin
Parent := Panels[PanelIndex];
Height := 20;
Visible := False;

case i of
EDIT_LOADS, EDIT_TIME, EDIT_LEVEL:
begin
Width := 40;
Left := (script_Lists[0].Left + script_Lists[0].Width - (Width + 40));
Top := (script_Lists[0].Top + script_Lists[0].Height + 20) + ((15 + Height) * i);
end;

EDIT_EXCEPTIONS, EDIT_ALCH_SLOTS, EDIT_PRIORITY:
begin
Width := 80;
Left := script_Lists[LIST_DROP].Left + (Width - 40);
Top := (script_Lists[0].Top + script_Lists[0].Height + 20) + ((15 + Height) * (i - 3));
end;
end;
end;
end;

// Edit TLabels
script_EditTexts := ['Loads', 'Time', 'Level', 'Exceptions', 'Alching Slots', 'Priority'];
for i := 0 to High(script_EditLabels) do
begin
script_EditLabels[i] := TLabel.Create(Panels[PanelIndex]);
with script_EditLabels[i] do
begin
Parent := Panels[PanelIndex];
Height := 25;
Width := (script_Edits[i].Width);
Left := script_Edits[i].Left - Width;
Top := (script_Edits[i].Top + 4);
Caption := script_EditTexts[i];
Font.Color := 2070783;
Visible := script_Edits[i].Visible;
end;
end;
end;

procedure script_HideComponents();
var
i: Integer;
begin
for i := 0 to High(script_Lists) do
script_Lists[i].Visible := False;

for i := 0 to High(script_Edits) do
script_Edits[i].Visible := False;

for i := 0 to High(script_ListLabels) do
script_ListLabels[i].Visible := False;

for i := 0 to High(script_EditLabels) do
script_EditLabels[i].Visible := False;
end;

procedure script_ShowComponents();
var
i, j, k: Integer;
default, lists, edits: TIntegerArray;
mode, index: Integer;
begin
script_HideComponents();

for i := 0 to High(MSI_Scripts) do
if (MSI_Scripts[i].Name = comboBox_Script_6.Text) then
begin
case MSI_Scripts[i].SkillConst of
SKILL_WOODCUTTING:
begin
lists := [LIST_TREES, LIST_DROP];
default := MSI_Scripts[i].Defaults.Trees;
end;

SKILL_MINING:
begin
lists := [LIST_ROCKS, LIST_DROP];
default := MSI_Scripts[i].Defaults.Rocks;
end;

SKILL_FISHING:
begin
lists := [LIST_FISHSPOTS, LIST_DROP];
default := MSI_Scripts[i].Defaults.FishSpots;
end;

SKILL_MAGIC:
begin
// Sets up spells if not already done so
if (not SpellSetup) then
SetupSpells;

// Adds all the spells to the Spells list
for j := 0 to High(MSI_Scripts[i].Defaults.Spells) do
begin
mode := MSI_GetSpellMode(MSI_Scripts[i].Defaults.Spells[j], index);
script_Lists[LIST_SPELLS].Items.Append(Capitalize(SpellModes[mode][index].Name));
end;

// Adds all the staffs to the Staff list
for j := 0 to High(MSI_Items) do
if (Pos('staff', Lowercase(MSI_Items[j].Name)) > 0) then
script_Lists[LIST_STAFFS].Items.Append(Capitalize(MSI_Items[j].Name));

// Makes all the required components visible
script_Lists[LIST_SPELLS].Visible := True;
script_Lists[LIST_STAFFS].Visible := True;
script_ListLabels[LIST_SPELLS].Visible := True;
script_ListLabels[LIST_STAFFS].Visible := True;
script_Edits[EDIT_TIME].Visible := True;
script_EditLabels[EDIT_TIME].Visible := True;

Exit;
end;
end;

// Lists and edits for Woodcutting, Mining and Woodcutting
edits := [EDIT_LOADS, EDIT_TIME, EDIT_EXCEPTIONS, EDIT_PRIORITY, EDIT_LEVEL];

script_Lists[lists[0]].CLEAR;

// Add the default objects to the TCheckListBox
for j := 0 to High(default) do
for k := 0 to High(MSI_Objects) do
if (default[j] = k) then
script_Lists[lists[0]].Items.Append(Capitalize(MSI_Objects[k].Name));

// Make lists visible
for j := 0 to High(lists) do
begin
script_Lists[lists[j]].Visible := True;
script_ListLabels[lists[j]].Visible := True;
end;

// Make edit boxes visible
for j := 0 to High(edits) do
begin
script_Edits[edits[j]].Visible := True;
script_EditLabels[edits[j]].Visible := True;
end;

Exit;
end;
end;

procedure script_FillComponents(pIndex: Integer);
begin
end;

procedure script_FillCombo();
var
i, pIndex: Integer;
begin
comboBox_Script_6.CLEAR;

pIndex := GetPlayerIndex(comboBox_Player_6.Text);

with MSI_Players[pIndex] do
for i := 0 to High(Scripts) do
comboBox_Script_6.Items.Append(MSI_Scripts[Scripts[i].Name].Name);
end;

procedure script_SetInfo();
begin
end;

(*
END OF SCRIPT SETUP COMPONENTS
==============================
*)

procedure OutsideBox(l,t,r,b, obj: integer);
begin
if tImages[obj].Left > l then
tImages[obj].Left := l;
if tImages[obj].Top > t then
tImages[obj].Top := t;
if tImages[obj].Left < r then
tImages[obj].Left := r;
if tImages[obj].Top < b then
tImages[obj].Top := b;
end;

procedure CheckScripts(PlayerIndex: Integer);
var
j, k: Integer;
begin
for j := 0 to High(MSI_Players[PlayerIndex].Scripts) do
for k := 0 to (CheckListBox_3.Items.Count - 1) do
if (Lowercase(MSI_Scripts[MSI_Players[PlayerIndex].Scripts[j].Name].Name) = Lowercase(CheckListBox_3.Items.Strings[k])) then
CheckListBox_3.Checked[k] := True;
end;

procedure CheckLocs(PlayerIndex: Integer);
var
j, k: Integer;
begin
with MSI_Players[PlayerIndex] do
for k := 0 to (CheckListBox_4.Items.Count - 1) do
if (Lowercase(MSI_Locations[Location].Name) = Lowercase(CheckListBox_4.Items.Strings[k])) then
begin
CheckListBox_4.Checked[k] := True;
Break;
end;
end;

procedure FillPanel5Edits(pIndex: Integer);
begin
time_Total_5.Text := IntToStr(MSI_Players[pIndex].TotalTime);
time_Break_5.Text := IntToStr(MSI_Players[pIndex].BreakTime);
loads_Break_5.Text := IntToStr(MSI_Players[pIndex].BreakLoads);
loads_Total_5.Text := IntToStr(MSI_Players[pIndex].TotalLoads);

time_Total_5.Enabled := True;
time_Break_5.Enabled := True;
loads_Break_5.Enabled := True;
loads_Total_5.Enabled := True;
end;

procedure AddToCombos(s: string);
var
i, j, k, pIndex: Integer;
begin
s := Capitalize(s);

combobox_3.Items.Append(s);
combobox_4.Items.Append(s);
comboBox_Player_5.Items.Append(s);
comboBox_Player_6.Items.Append(s);

{if (comboBox_3.Text = '') then
begin
comboBox_3.Text := s;
pIndex := GetPlayerIndex(s);
//Writeln(IntToStr(pIndex));
CheckScripts(pIndex);
end;


if (comboBox_4.Text = '') then
comboBox_4.Text := s;

if (comboBox_Player_5.Text = '') then
comboBox_Player_5.Text := s;

if (comboBox_Player_6.Text = '') then
comboBox_Player_6.Text := s;}
end;

function SetScriptConsts(): TIntegerArray;
var
i, j: Integer;
begin
for i := 0 to (CheckListBox_3.Items.Count - 1) do
if (CheckListBox_3.Checked[i]) then
for j := 0 to High(MSI_Scripts) do
begin
if (MSI_Scripts[j].Name = '') then
Continue;

if (Lowercase(CheckListBox_3.Items.Strings[i]) = Lowercase(MSI_Scripts[j].Name)) then
begin
SetLength(Result, Length(Result) + 1);
Result[High(Result)] := MSI_Scripts[j].Constant;
end;
end;

for i := 0 to High(MSI_Players) do
if (Lowercase(comboBox_3.Text) = Lowercase(MSI_Players[i].Name)) then
begin
SetLength(MSI_Players[i].Scripts, Length(Result));

for j := 0 to High(MSI_Players[i].Scripts) do
begin
MSI_Players[i].Scripts[j].Name := Result[j];
//Writeln(IntToStr(MSI_Players[i].Scripts[j].Name));
end;

Break;
end;

Writeln('Scripts: ' + ToStr(Result));
end;

function SetLocConsts(): Integer;
var
i, j: Integer;
begin
for i := 0 to (CheckListBox_4.Items.Count - 1) do
if (CheckListBox_4.Checked[i]) then
for j := 0 to High(MSI_Locations) do
begin
if (MSI_Locations[j].Name = '') then
Continue;

if (Lowercase(CheckListBox_4.Items.Strings[i]) = Lowercase(MSI_Locations[j].Name)) then
begin
Result := MSI_Locations[j].Constant;
Break;
end;
end;

for i := 0 to High(MSI_Players) do
if (Lowercase(comboBox_4.Text) = Lowercase(MSI_Players[i].Name)) then
begin
MSI_Players[i].Location := Result;
Writeln('Location: ' + ToStr(MSI_Players[i].Location));
Break;
end;

end;

procedure SetOther();
var
i: Integer;
begin
for i := 0 to High(MSI_Players) do
if (Lowercase(comboBox_Player_5.Text) = Lowercase(MSI_Players[i].Name)) then
with MSI_Players[i] do
begin
try
TotalTime := StrToInt(time_Total_5.Text);
except
ShowMessage('Total time must be a number!');
Exit;
end;

try
BreakTime := StrToInt(time_Break_5.Text);
except
ShowMessage('Break after (time) must be a number!');
Exit;
end;

try
BreakLoads := StrToInt(loads_Break_5.Text);
except
ShowMessage('Break after (loads) must be a number!');
Exit;
end;

try
TotalLoads := StrToInt(loads_Total_5.Text);
except
ShowMessage('Total loads must be a number!');
Exit;
end;

Break;
end;

Writeln('Others set!');
end;

procedure IntroVisible(Visible: Boolean);
begin
// Show/hide components on the introduction tab
if (not Visible) then
begin
end else begin
end;
end;

const
MAX_MOVE = 315;

var
accel, pMoved, senderTab, pan: integer;
onLeft: Boolean;

procedure TimerTabClick(Sender: TObject);
var
i, e, d, hi, lo: Integer;
begin
accel := accel + 2;
pMoved := pMoved + accel;

if (senderTab = IMG_TAB_NORM_0) then
begin
for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_5 do
begin
if (not isLeftTab[i]) then
Continue;

tImages[i].Left := tImages[i].Left + accel;

if (pMoved >= MAX_MOVE) then
begin
isLeftTab[i] := False;
time.Enabled := False;
tImages[i].Left := tImages[i].Left - 5;
IntroVisible(True);
end;
end;
end else
begin
if (onLeft) then
for i := senderTab to IMG_TAB_NORM_5 do
begin
if (i = senderTab) or (not isLeftTab[i]) then
Continue;

tImages[i].Left := tImages[i].Left + accel;

if (pMoved >= MAX_MOVE) then
begin
isLeftTab[i] := False;
time.Enabled := False;
tImages[i].Left := tImages[i].Left - 5;
end;

//Writeln(BoolToStr(isLeftTab[i]));
end
else
for i := senderTab downto IMG_TAB_NORM_1 do
begin
if (isLeftTab[i]) then
Continue;

tImages[i].Left := tImages[i].Left - accel;

if (pMoved >= MAX_MOVE) then
begin
isLeftTab[i] := True;
time.Enabled := False;
tImages[i].Left := tImages[i].Left + 5;
end;

IntroVisible(False);
end;
end;

for i := IMG_TAB_NORM_1 to high(panels) do
begin
panels[i].left := tImages[i].left + tImages[i].width + 2
if i <> high(Panels) then
panels[i].width := tImages[i + 1].left - panels[i].left - 2
else
panels[i].width := form_Main.width - panels[i].left - 10;
end;
end;

procedure TabClick(Sender: TObject);
var
i: integer;
begin
if not time.ENABLED then
begin
accel := 0;
pMoved := 0;
time.enabled := true;
pan := senderTab;

if (Sender = tImages[IMG_TAB_NORM_0]) then
senderTab := IMG_TAB_NORM_0;

for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_5 do
if (Sender = tImages[i]) then
begin
senderTab := i;
if (isLeftTab[senderTab]) then
onLeft := True
else
onLeft := False;
end;
end;
end;

procedure Clicked(Sender: TObject);
var
i: Integer;
begin
for i := 0 to BITMAP_COUNT - 1 do
FreeBitmap(frmBitmaps[i]);
form_Main.ModalResult := mrOk;
end;

procedure MouseMoved(Sender: TObject; Shift: TShiftState; x, y: Integer);
var
x1, y1, hi, i, j, bmp, xdif, ydif, h: Integer;
BoundL, BoundT: Extended;
imgSwap, bmpArr, imgArr: Array of Integer;
begin
bmpArr := [ X_NORM, Q_NORM, LOAD_TAB_NORM,
SAVE_TAB_NORM, TAB_NORM_1, TAB_NORM_2,
TAB_NORM_3, TAB_NORM_4, TAB_NORM_5, TAB_NORM_0 ];

imgArr := [ IMG_X_NORM, IMG_Q_NORM, IMG_LOAD_TAB_NORM,
IMG_SAVE_TAB_NORM, IMG_TAB_NORM_1, IMG_TAB_NORM_2,
IMG_TAB_NORM_3, IMG_TAB_NORM_4, IMG_TAB_NORM_5, IMG_TAB_NORM_0 ];

hi := High(bmpArr);
case Sender of
tImages[IMG_BGND], Panels[IMG_TAB_NORM_1],
Panels[IMG_TAB_NORM_2], Panels[IMG_TAB_NORM_3], Panels[IMG_TAB_NORM_4],
Panels[IMG_TAB_NORM_5]:
begin
for i := 0 to hi do
begin
if (not isActiveImage[imgArr[i]]) then
Continue;

bmp := frmBitmaps[bmpArr[i]];
DrawBitmap(bmp,tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;
end;

for h := 0 to hi do
case Sender of
tImages[imgArr[h]]:
begin
imgSwap := [imgArr[h], frmBitmaps[bmpArr[h] + 1]];
if not (isActiveImage[imgSwap[0]]) then
begin
DrawBitmap(imgSwap[1],tImages[imgSwap[0]].Canvas,0,0);
isActiveImage[imgSwap[0]] := True;
for i := 0 to hi do
begin
if (Sender = tImages[imgArr[i]]) then
Continue;

if (not isActiveImage[imgArr[i]]) then
Continue;

if (i = imgSwap[0] - 1) then
Continue;

bmp := frmBitmaps[bmpArr[i]];
DrawBitmap(bmp, tImages[imgArr[i]].Canvas,0,0);
isActiveImage[imgArr[i]] := False;
end;
end;
end;
end;
end;

procedure SavePlayers();
var
i, j: Integer;
s: string;
begin
WriteINI('Number of Players', 'NumberOfPlayers', IntToStr(Length(MSI_Players)), PATH_PLAYER);

for i := 0 to High(MSI_Players) do
with MSI_Players[i] do
begin
s := '';
Active := UserList.Checked[i];
SetLocConsts;

WriteINI(IntToStr(i), 'Name', Name, PATH_PLAYER);
WriteINI(IntToStr(i), 'Pass', Pass, PATH_PLAYER);
WriteINI(IntToStr(i), 'Nick', Nick, PATH_PLAYER);
WriteINI(IntToStr(i), 'Pin', Pin, PATH_PLAYER);
WriteINI(IntToStr(i), 'Active', BoolToStr(Active), PATH_PLAYER);
WriteINI(IntToStr(i), 'Member', BoolToStr(Member), PATH_PLAYER);
WriteINI(IntToStr(i), 'Location', IntToStr(Location), PATH_PLAYER);
WriteINI(IntToStr(i), 'BreakTime', IntToStr(BreakTime), PATH_PLAYER);
WriteINI(IntToStr(i), 'BreakLoads', IntToStr(BreakLoads), PATH_PLAYER);
WriteINI(IntToStr(i), 'TotalTime', IntToStr(TotalTime), PATH_PLAYER);
WriteINI(IntToStr(i), 'TotalLoads', IntToStr(TotalLoads), PATH_PLAYER);

WriteINI(IntToStr(i), 'NumberOfScripts', IntToStr(Length(Scripts)), PATH_PLAYER);
for j := 0 to High(Scripts) do
begin
WriteINI(IntToStr(i), 'Script'+IntToStr(j)+'.Name', IntToStr(Scripts[j].Name), PATH_PLAYER);
end;
end;

ShowMessage('Saved Players!');
end;

procedure LoadPlayers();
var
i, j: Integer;
nPlayers, s, p: string;
begin
if (not tImages[IMG_LOAD_TAB_NORM].Enabled) then
begin
ShowMessage('Already loaded players!');
Exit;
end;

nPlayers := ReadINI('Number of Players', 'NumberOfPlayers', PATH_PLAYER);
SetLength(MSI_Players, StrToInt(nPlayers));

for i := 0 to High(MSI_Players) do
with MSI_Players[i] do
begin
Name := ReadINI(IntToStr(i), 'Name', PATH_PLAYER);
Pass := ReadINI(IntToStr(i), 'Pass', PATH_PLAYER);
Nick := ReadINI(IntToStr(i), 'Nick', PATH_PLAYER);
Pin := ReadINI(IntToStr(i), 'Pin', PATH_PLAYER);
Active := StrToBool(ReadINI(IntToStr(i), 'Active', PATH_PLAYER));
Member := StrToBool(ReadINI(IntToStr(i), 'Member', PATH_PLAYER));
Location := StrToInt(ReadINI(IntToStr(i), 'Location', PATH_PLAYER));
BreakTime := StrToInt(ReadINI(IntToStr(i), 'BreakTime', PATH_PLAYER));
BreakLoads := StrToInt(ReadINI(IntToStr(i), 'BreakLoads', PATH_PLAYER));
TotalTime := StrToInt(ReadINI(IntToStr(i), 'TotalTime', PATH_PLAYER));
TotalLoads := StrToInt(ReadINI(IntToStr(i), 'TotalLoads', PATH_PLAYER));

if (Member) then
begin
comboBox_Member.Text := 'True';
s := '[P2P] '
end else begin
comboBox_Member.Text := 'False';
s := '[F2P] ';
end;

if (Pin <> '') then
p := 'Pin';

UserList.Items.Append(s + Capitalize(Name) + ' (' + Pass + ')' + p + Pin);
UserList.Checked[i] := Active;

AddToCombos(Name);

SetLength(Scripts, StrToInt(ReadINI(IntToStr(i), 'NumberOfScripts', PATH_PLAYER)));
for j := 0 to High(Scripts) do
begin
Scripts[j].Name := StrToInt(ReadINI(IntToStr(i), 'Script'+IntToStr(j)+'.Name', PATH_PLAYER));

end;
end;

tImages[IMG_LOAD_TAB_NORM].Enabled := False;
btn_DeletePlayer.Enabled := (Length(MSI_Players) > 1);
ShowMessage('Loaded Players!');
end;

procedure OnClickEvents(Sender: TObject); // OnClick
var
i, j, t: integer;
bmpArr, tScripts: TIntegerArray;
begin
for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_5 do
if (isLeftTab[i]) then
Inc(t);

for i := IMG_TAB_NORM_1 to IMG_TAB_NORM_5 do
case Sender of
tImages[i]:
begin
if (isLeftTab[i]) then
if (t <= (i - (IMG_TAB_NORM_5 - IMG_TAB_NORM_1))) then
Exit;

TabClick(Sender);

if (not isLeftTab[i]) then
begin
bmpArr := [TAB_NORM_1, TAB_NORM_2, TAB_NORM_3, TAB_NORM_4, TAB_NORM_5];
DrawBitmap(frmBitmaps[bmpArr[i-IMG_TAB_NORM_1]], tImages[i].Canvas, 0, 0);
end;
end;
end;

case Sender of
tImages[IMG_X_NORM]: Clicked(Sender);
tImages[IMG_Q_NORM]: OpenWebPage('http://villavu.com/forum/showthread.php?t=57723');

tImages[IMG_TAB_NORM_0]:
begin
if (t <= 0) then
Exit;

TabClick(Sender);
end;

tImages[IMG_SAVE_TAB_NORM]:
begin
DrawBitmap(frmBitmaps[SAVE_TAB_NORM],tImages[IMG_SAVE_TAB_NORM].Canvas,0,0);
SetScriptConsts;
SetLocConsts;
SetOther;
SavePlayers;
end;

tImages[IMG_LOAD_TAB_NORM]:
begin
DrawBitmap(frmBitmaps[LOAD_TAB_NORM],tImages[IMG_LOAD_TAB_NORM].Canvas,0,0);
LoadPlayers;
end;

comboBox_3:
begin
pBoxIndex := comboBox_3.ItemIndex;
SetScriptConsts;
end;

comboBox_4:
begin
pBoxIndex := comboBox_4.ITEMINDEX;
SetLocConsts;
end;

comboBox_Player_5:
begin
pBoxIndex := comboBox_Player_5.ItemIndex;
SetOther();
end;

comboBox_Player_6:
begin
pBoxIndex := comboBox_Player_6.ITEMINDEX;
script_SetInfo();
end;
end;
end;

{******************************************************************************}
{ Name: Form_OnKeyPress }
{ By: SKy Scripter }
{ Description: Keeps stupid people from typing in the combobox }
{******************************************************************************}
procedure OnKeyPress(Sender: TObject; var Key: Char);
begin
Key := Chr(VK_CANCEL);
end;

{******************************************************************************}
{ Name: function GenerateNick(Username: string): string; }
{ By: Coh3n }
{ Description: Generates the players nickname based on their username }
{******************************************************************************}
function GenerateNick(Username: string): string;
var
i, j: Integer;
s: TStringArray;
begin
s := Explode(' ', Username);
for i := 0 to High(s) do
if (Length(s[i]) >= 4) then
begin
for j := 2 to 4 do
Result := Result + s[i][j];

Break;
end;

//Writeln('Username: ' + Username);
//Writeln('Nickname: ' + Result);
end;

{******************************************************************************}
{ Name: procedure AddPlayer(); }
{ By: Coh3n }
{ Description: Adds a player to the player array. Called when the Add Player }
{ button is pressed }
{******************************************************************************}
procedure AddPlayer();
var
h: Integer;
begin
SetLength(MSI_Players, Length(MSI_Players) + 1);
btn_DeletePlayer.Enabled := (Length(MSI_Players) > 1);

h := High(MSI_Players);
with MSI_Players[h] do
begin
Name := edit_User.Text;
Pass := edit_Pass.Text;
Nick := GenerateNick(Name);
Pin := edit_Pin.Text;
Active := UserList.Checked[UserList.ItemIndex];
Member := StrToBool(comboBox_Member.Text);

Writeln(Name);
Writeln(Pass);
Writeln(Nick);
Writeln(Pin);
Writeln(BoolToStr(Active));
Writeln(BoolToStr(Member));
end;

Writeln('Player Length: ' + IntToStr(Length(MSI_Players)));
end;

{******************************************************************************}
{ Name: procedure RemovePlayer(); }
{ By: Masterkill & Coh3n }
{ Description: Removes a player from the player array. Called when the Remove }
{ Player button is pressed }
{******************************************************************************}
procedure RemovePlayer();
var
i: Integer;
begin
Writeln(IntToStr(UserList.ItemIndex));
if (not (UserList.ItemIndex = High(MSI_Players))) then
if (UserList.ItemIndex + 1 = High(MSI_Players)) then
MSI_Players[UserList.ItemIndex] := MSI_Players[High(MSI_Players)]
else
for i := UserList.ItemIndex to High(MSI_Players) - 1 do
MSI_Players[i] := MSI_Players[i + 1];

btn_DeletePlayer.Enabled := (Length(MSI_Players) > 1);

SetLength(MSI_Players, Length(MSI_Players) - 1);
Writeln('Player Length: ' + IntToStr(Length(MSI_Players)));
end;

procedure Panel2Clicks(Sender: TObject); // OnChange
var
sel: integer;
s, p: string;
begin
case sender of
btn_AddPlayer:
begin
if (StrToBool(comboBox_Member.Text)) then
s := '[P2P] '
else
s := '[F2P] ';

if (edit_Pin.Text <> '') then
p := 'Pin';

UserList.Items.Append(s + Capitalize(edit_User.Text) + ' (' + edit_Pass.Text + ')' + p + edit_Pin.Text);

// Add player to the combo box on other panels
AddToCombos(edit_User.Text);

UserList.Checked[UserList.items.Count - 1] := true;
UserList.ItemIndex := UserList.Items.Count - 1;

AddPlayer();

edit_User.Text := '';
edit_Pass.Text := '';
edit_Pin.Text := '';
end;

btn_DeletePlayer:
begin
if UserList.ItemIndex >= 0 then
sel := UserList.ItemIndex;
UserList.Items.Delete(sel);
combobox_3.Items.Delete(sel);
combobox_4.Items.Delete(sel);
if sel = 0 then
sel := 1;
UserList.ItemIndex := sel - 1;

RemovePlayer();

edit_User.Text := '';
edit_Pass.Text := '';
edit_Pin.Text := '';
end;
end;
end;

procedure Panel3Clicks(Sender: TObject); // OnChange
var
i, j: Integer;
pIndex: Integer;
begin
case sender of
Add_3:
if Combobox_3.ITEMINDEX > 0 then
combobox_3.ItemIndex := combobox_3.ItemIndex - 1;

ComboBox_3:
begin
for i := 0 to CheckListBox_3.ITEMS.Count - 1 do
CheckListBox_3.Checked[i] := False;

pIndex := GetPlayerIndex(comboBox_3.Text);
CheckScripts(pIndex);
CheckListBox_3.Enabled := True;
end;

Delete_3:
if Combobox_3.ITEMINDEX < Combobox_3.ITEMS.Count then
begin
pBoxIndex := ComboBox_3.ItemIndex;
Writeln(IntToStr(pBoxIndex));

SetScriptConsts;
pIndex := GetPlayerIndex(comboBox_3.Items.Strings[pBoxIndex]);
CheckScripts(pIndex);

combobox_3.ItemIndex := combobox_3.ItemIndex + 1;

for i := 0 to CheckListBox_3.ITEMS.Count - 1 do
CheckListBox_3.Checked[i] := False;
end;
end;
end;

procedure Panel4Clicks(Sender: TObject); // OnChange
var
i, pIndex: Integer;
begin
case sender of
Add_4:
if Combobox_4.ITEMINDEX > 0 then
combobox_4.ItemIndex := combobox_4.ItemIndex - 1;

ComboBox_4:
begin
for i := 0 to CheckListBox_4.ITEMS.Count - 1 do
CheckListBox_4.Checked[i] := False;

pIndex := GetPlayerIndex(comboBox_4.Text);
Writeln('Player Index: '+IntToStr(pIndex));

CheckLocs(pIndex);
CheckListBox_4.Enabled := True;
end;

Delete_4:
if Combobox_4.ITEMINDEX < Combobox_4.ITEMS.Count then
combobox_4.ItemIndex := combobox_4.ItemIndex + 1;
end;
end;

procedure Panel5Clicks(Sender: TObject); // OnChange
var
pIndex:Integer;
begin
case sender of
{Add_5:
if ComboBox_Player_5.ITEMINDEX > 0 then
ComboBox_Player_5.ItemIndex := ComboBox_Player_5.ItemIndex - 1;}

ComboBox_Player_5:
begin
pIndex := GetPlayerIndex(comboBox_Player_5.Text);
Writeln('Player Index: '+IntToStr(pIndex));

FillPanel5Edits(pIndex);
end;

{Delete_5:
if ComboBox_Player_5.ITEMINDEX < ComboBox_Player_5.ITEMS.Count then
ComboBox_Player_5.ItemIndex := ComboBox_Player_5.ItemIndex + 1;}
end;
end;

procedure Panel6Clicks(Sender: TObject); // OnChange
var
pIndex: Integer;
begin
case sender of
prevPlayer:
if ComboBox_Player_6.ITEMINDEX < ComboBox_Player_6.ITEMS.Count then
ComboBox_Player_6.ItemIndex := ComboBox_Player_6.ItemIndex + 1;

ComboBox_Player_6:
begin
SetScriptConsts();
script_FillCombo();
script_HideComponents();
end;

ComboBox_Script_6:
begin
script_ShowComponents();

pIndex := GetPlayerIndex(comboBox_4.Text);
script_FillComponents(pIndex);
end;

nextPlay:
if ComboBox_Player_6.ITEMINDEX > 0 then
ComboBox_Player_6.ItemIndex := ComboBox_Player_6.ItemIndex - 1;

nScript:
if ComboBox_Script_6.ITEMINDEX < ComboBox_Script_6.ITEMS.Count then
ComboBox_Script_6.ItemIndex := ComboBox_Script_6.ItemIndex + 1;

pScript:
if ComboBox_Script_6.ITEMINDEX > 0 then
ComboBox_Script_6.ItemIndex := ComboBox_Script_6.ItemIndex - 1;
end;
end;

procedure InitForm;
var
i, pan: Integer;
consts: TintegerArray;
bmpArr: TStringArray;
xy: TPointArray;
visibl: array of boolean;
wh: TPoint;
begin
bmpArr := ['BGND','X_NORM','X_HOVER','Q_NORM','Q_HOVER','LOAD_TAB_NORM','LOAD_TAB_HOVER','SAVE_TAB_NORM','SAVE_TAB_HOVER','TAB_NORM_1','TAB_HOVER_1','TAB_NORM_2','TAB_HOVER_2','TAB_NORM_3','TAB_HOVER_3','TAB_NORM_4','TAB_HOVER_4','TAB_NORM_5','TAB_HOVER_5','TAB_NORM_0','TAB_HOVER_0', 'BGND_PANEL'];
for i := 0 to High(frmBitmaps) do
frmBitmaps[i] := LoadBitmap(ScriptPath + 'Bitmaps\' + bmpArr[i] + '.png');

form_Main := TForm.Create(nil);
form_Main.SetBounds({L} 100, {T} 100, {W} 600, {H} 400);
form_Main.Position := poScreenCenter;
form_Main.BorderStyle := bsNone;

time := TTimer.Create(form_Main);
with time do
begin
ONTIMER := @TimerTabClick;
INTERVAL := 10;
ENABLED := false;
end;

xy := [Point(0,0), Point(575,7), Point(557,7), Point(7,69), Point(81,69), Point(386, 100), Point(427,100), Point(468,100), Point(509,100), Point(550,100), Point(8, 222) ];
SetArrayLength(visibl, GetArrayLength(xy));
consts := [BGND, X_NORM, Q_NORM, LOAD_TAB_NORM,SAVE_TAB_NORM,TAB_NORM_1, TAB_NORM_2, TAB_NORM_3, TAB_NORM_4, TAB_NORM_5, TAB_NORM_0 ];

for i := low(panels) to high(panels) do
begin
panels[i] := TPanel.Create(form_Main);
panels[i].parent := form_Main;
GetBitmapSize(frmBitmaps[consts[i]], wh.x, wh.y);
panels[i].SetBounds(xy[i].x + wh.x, xy[i].y, 0, wh.y);
panels[i].BEVELWIDTH := 0;

bgndPanel := TImage.Create(panels[i]);
bgndPanel.Parent := panels[i];
bgndPanel.Visible := True;
GetBitmapSize(frmBitmaps[BGND_PANEL], a, b);
bgndPanel.SetBounds(0, 0, a, b);
DrawBitmap(frmBitmaps[BGND_PANEL], bgndPanel.Canvas, 0, 0);
end;

pan := IMG_TAB_NORM_1;



for i := 0 to IMG_COUNT - 1 do
begin
tImages[i] := TImage.Create(form_Main)
with tImages[i] do
begin
Parent := form_Main;
GetBitmapSize(frmBitmaps[consts[i]], wh.x, wh.y);
SetBounds(xy[i].x, xy[i].y, wh.x, wh.y);
OnMouseMove := @MouseMoved;
OnClick := @OnClickEvents;
isActiveImage[i] := False;
end;
DrawBitmap(frmBitmaps[consts[i]], tImages[i].canvas, 0, 0);
end;

UserList := TCheckListBox.Create(panels[pan]);
UserList.Parent := panels[pan];
UserList.SetBounds(10, 55, 225, 220);

Label_2 := TLabel.Create(panels[pan]);
Label_2.Parent := panels[pan];
Label_2.Setbounds(245,55,50,13);
Label_2.Caption := 'Username';
Label_2.Font.Color := 2070783;

edit_User := TEdit.Create(panels[pan]);
edit_User.Parent := panels[pan];
edit_User.SetBounds(label_2.left,Label_2.top + Label_2.height + 5,83,21);

Label2_2 := TLabel.Create(panels[pan]);
Label2_2.Parent := panels[pan];
Label2_2.Setbounds(label_2.left, edit_User.top + edit_User.height + 10,32,13);
Label2_2.Caption := 'Password';
Label2_2.Font.Color := 2070783;

edit_Pass := TEdit.Create(panels[pan]);
edit_Pass.Parent := panels[pan];
edit_Pass.SetBounds(label_2.left,Label2_2.top + Label2_2.height + 5,83,21);

pin_P2 := TLabel.Create(panels[pan]);
pin_P2.Parent := panels[pan];
pin_P2.Setbounds(label_2.left, edit_Pass.top + edit_Pass.height + 10,32,13);
pin_P2.Caption := 'Pin';
pin_P2.Font.Color := 2070783;

edit_Pin := TEdit.Create(panels[pan]);
edit_Pin.Parent := panels[pan];
edit_Pin.SetBounds(label_2.left, pin_P2.top + pin_P2.height + 5, 83, 21);
edit_Pin.MaxLength := 4;

label_Member := TLabel.Create(panels[pan]);
label_Member.Parent := panels[pan];
label_Member.Setbounds(label_2.left, edit_Pin.top + edit_Pin.height + 10,32,13);
label_Member.Caption := 'Members';
label_Member.Font.Color := 2070783;

comboBox_Member := TComboBox.Create(panels[pan]);
comboBox_Member.Parent := panels[pan];
comboBox_Member.SetBounds(label_2.left, label_Member.top + label_Member.height + 5, 83, 21);
comboBox_Member.OnKeyPress := @OnKeyPress;
comboBox_Member.Items.Add('True');
comboBox_Member.Items.Add('False');
comboBox_Member.Text := 'False';

btn_AddPlayer := TButton.Create(panels[pan]);
btn_AddPlayer.Parent := panels[pan];
btn_AddPlayer.Setbounds(22,22,95,25);
btn_AddPlayer.Caption := 'Add Player';
btn_AddPlayer.ONCLICK := @Panel2Clicks;

btn_DeletePlayer := TButton.Create(panels[pan]);
btn_DeletePlayer.Parent := panels[pan];
btn_DeletePlayer.SetBounds(btn_AddPlayer.left+btn_AddPlayer.width+10,btn_AddPlayer.top,btn_AddPlayer.width,btn_AddPlayer.height);
btn_DeletePlayer.Caption := 'Remove Player';
btn_DeletePlayer.OnClick := @Panel2Clicks;
btn_DeletePlayer.Enabled := (Length(MSI_Players) > 1);

inst_P2 := TLabel.Create(panels[pan]);
inst_P2.Parent := panels[pan];
inst_P2.SetBounds(50,3,73,25);
inst_P2.Caption := 'Input player information and click Add Player';
inst_P2.Font.Color := 2070783;





pan := IMG_TAB_NORM_2;

Add_3 := TButton.Create(panels[pan]);
Add_3.Parent := panels[pan];
Add_3.SetBounds(35,24,73,25);
Add_3.Caption := 'Previous';
Add_3.OnClick := @Panel3Clicks;
Add_3.Visible := False;

inst_P3 := TLabel.Create(panels[pan]);
inst_P3.Parent := panels[pan];
inst_P3.SetBounds(60,3,73,25);
inst_P3.Caption := 'Choose a script(s) for each player to use';
inst_P3.Font.Color := 2070783;

ComboBox_3 := TComboBox.Create(panels[pan]);
ComboBox_3.Parent := panels[pan];
ComboBox_3.SetBounds(add_3.left + add_3.width,add_3.top,115,21);
ComboBox_3.OnChange := @Panel3Clicks;
ComboBox_3.OnClick := @OnClickEvents;
ComboBox_3.OnKeyPress := @OnKeyPress;

Delete_3 := TButton.Create(panels[pan]);
Delete_3.Parent := panels[pan];
Delete_3.SetBounds(ComboBox_3.left + ComboBox_3.width + 5,add_3.top,75,25);
Delete_3.Caption := 'Next';
Delete_3.OnClick := @Panel3Clicks;
Delete_3.Visible := False;

CheckListBox_3 := TCheckListBox.Create(panels[pan]);
CheckListBox_3.Parent := panels[pan];
CheckListBox_3.SetBounds(10, 55, 315, 220);
for i := 0 to High(MSI_Scripts) do
begin
if (MSI_Scripts[i].Name = '') then
Continue;

CheckListBox_3.Items.Add(Capitalize(MSI_Scripts[i].Name));
end;

CheckListBox_3.Enabled := False;




pan := IMG_TAB_NORM_3;

Add_4 := TButton.Create(panels[pan]);
Add_4.Parent := panels[pan];
Add_4.SetBounds(35,24,73,25);
Add_4.Caption := 'Previous';
Add_4.OnClick := @Panel4Clicks;
Add_4.Visible := False;

ComboBox_4 := TComboBox.Create(panels[pan]);
ComboBox_4.Parent := panels[pan];
ComboBox_4.SetBounds(add_4.left + add_4.width,add_4.top,115,21);
ComboBox_4.OnChange := @Panel4Clicks;
ComboBox_4.OnClick := @OnClickEvents;
ComboBox_4.OnKeyPress := @OnKeyPress;

Delete_4 := TButton.Create(panels[pan]);
Delete_4.Parent := panels[pan];
Delete_4.SetBounds(ComboBox_4.left + ComboBox_4.width + 5,add_4.top,75,25);
Delete_4.Caption := 'Next';
Delete_4.OnClick := @Panel4Clicks;
Delete_4.Visible := False;

CheckListBox_4 := TCheckListBox.Create(panels[pan]);
CheckListBox_4.Parent := panels[pan];
CheckListBox_4.SetBounds(10, 55, 315, 220);
for i := 0 to High(MSI_Locations) do
begin
if (MSI_Locations[i].Name = '') or (MSI_Locations[i].Name = 'Lost') then
Continue;

CheckListBox_4.Items.Append(Capitalize(MSI_Locations[i].Name));
end;
CheckListBox_4.Enabled := False;

inst_P4 := TLabel.Create(panels[pan]);
inst_P4.Parent := panels[pan];
inst_P4.SetBounds(85, 3, 73, 25);
inst_P4.Caption := 'Set a location for each player';
inst_P4.Font.Color := 2070783;




pan := IMG_TAB_NORM_4;

Add_5 := TButton.Create(panels[pan]);
Add_5.Parent := panels[pan];
Add_5.SetBounds(35,24,73,25);
Add_5.Caption := 'Previous';
Add_5.OnClick := @Panel5Clicks;
Add_5.Visible := False;

ComboBox_Player_5 := TComboBox.Create(panels[pan]);
ComboBox_Player_5.Parent := panels[pan];
ComboBox_Player_5.SetBounds(add_5.left + add_5.width,add_5.top,115,21);
ComboBox_Player_5.OnChange := @Panel5Clicks;
ComboBox_Player_5.OnClick := @OnClickEvents;
ComboBox_Player_5.OnKeyPress := @OnKeyPress;

Delete_5 := TButton.Create(panels[pan]);
Delete_5.Parent := panels[pan];
Delete_5.SetBounds(ComboBox_Player_5.left + ComboBox_Player_5.width + 5,add_5.top,75,25);
Delete_5.Caption := 'Next';
Delete_5.OnClick := @Panel5Clicks;
Delete_5.Visible := False;

inst_P5 := TLabel.Create(panels[pan]);
inst_P5.Parent := panels[pan];
inst_P5.SetBounds(38, 3, 73, 25);
inst_P5.Caption := 'Set all other required information for each player';
inst_P5.Font.Color := 2070783;

time_Total_5 := TEdit.Create(panels[pan]);
time_Total_5.Parent := panels[pan];
time_Total_5.SetBounds(180, 60, 83, 21);
time_Total_5.Text := '0';
time_Total_5.Enabled := False;

loads_Total_5 := TEdit.Create(panels[pan]);
with loads_Total_5 do
begin
Parent := panels[pan];
SetBounds(time_Total_5.Left, time_Total_5.Top + time_Total_5.Height + 10, 83, 21);
Text := '0';
Enabled := False;
end;

time_Break_5 := TEdit.Create(panels[pan]);
time_Break_5.Parent := panels[pan];
time_Break_5.SetBounds(time_Total_5.Left, loads_Total_5.Top + loads_Total_5.Height + 10, 83, 21);
time_Break_5.Text := '0';
time_Break_5.Enabled := False;

loads_Break_5 := TEdit.Create(panels[pan]);
loads_Break_5.Parent := panels[pan];
loads_Break_5.SetBounds(time_Total_5.Left, time_Break_5.Top + time_Break_5.Height + 10, 83, 21);
loads_Break_5.Text := '0';
loads_Break_5.Enabled := False;

timeTotal := TLabel.Create(panels[pan]);
timeTotal.Parent := panels[pan];
timeTotal.Setbounds(55, 63,32,13);
timeTotal.Caption := 'Total Time (minutes)';
timeTotal.Font.Color := 2070783;

loadsTotal := TLabel.Create(panels[pan]);
with loadsTotal do
begin
Parent := panels[pan];
Setbounds(timeTotal.Left, timeTotal.Top + time_total_5.height + 10,32,13);
Caption := 'Total Loads';
Font.Color := 2070783;
end;

timeBreak := TLabel.Create(panels[pan]);
timeBreak.Parent := panels[pan];
timeBreak.Setbounds(timeTotal.Left, loadsTotal.Top + loads_total_5.height + 10,32,13);
timeBreak.Caption := 'Break After (minutes)';
timeBreak.Font.Color := 2070783;

loadsBreak := TLabel.Create(panels[pan]);
loadsBreak.Parent := panels[pan];
loadsBreak.Setbounds(timeTotal.Left, timeBreak.Top + time_Break_5.Height+10,32,13);
loadsBreak.Caption := 'Break After (loads)';
loadsBreak.Font.Color := 2070783;



pan := IMG_TAB_NORM_5;

script_CreateComponents(pan);

nextPlay := TButton.Create(panels[pan]);
nextPlay.Parent := panels[pan];
nextPlay.SetBounds(35,24,73,25);
nextPlay.Caption := 'Previous';
nextPlay.OnClick := @Panel6Clicks;
nextPlay.Visible := False;

ComboBox_Player_6 := TComboBox.Create(panels[pan]);
ComboBox_Player_6.Parent := panels[pan];
ComboBox_Player_6.SetBounds(45,nextPlay.top,115,21);
ComboBox_Player_6.OnChange := @Panel6Clicks;
ComboBox_Player_6.OnKeyPress := @OnKeyPress;
ComboBox_Player_6.OnClick := @OnClickEvents;

PrevPlayer := TButton.Create(panels[pan]);
PrevPlayer.Parent := panels[pan];
PrevPlayer.SetBounds(ComboBox_Player_6.left + ComboBox_Player_6.width + 5,nextPlay.top,75,25);
PrevPlayer.Caption := 'Next';
PrevPlayer.OnClick := @Panel6Clicks;
PrevPlayer.Visible := False;

nScript := TButton.Create(panels[pan]);
nScript.Parent := panels[pan];
nScript.SetBounds(nextPlay.Left,nextPlay.Top+nextPlay.Height+10,73,25);
nScript.Caption := 'Previous';
nScript.OnClick := @Panel6Clicks;
nScript.Visible := False;

ComboBox_Script_6 := TComboBox.Create(panels[pan]);
ComboBox_Script_6.Parent := panels[pan];
ComboBox_Script_6.SetBounds(175,ComboBox_Player_6.top,115,21);
ComboBox_Script_6.Text := '';
ComboBox_Script_6.OnChange := @Panel6Clicks;
ComboBox_Script_6.OnKeyPress := @OnKeyPress;

pScript := TButton.Create(panels[pan]);
pScript.Parent := panels[pan];
pScript.SetBounds(ComboBox_Script_6.left + ComboBox_Script_6.width + 5,nScript.top,75,25);
pScript.Caption := 'Next';
pScript.OnClick := @Panel6Clicks;
pScript.Visible := False;

inst_P6 := TLabel.Create(panels[pan]);
inst_P6.Parent := panels[pan];
inst_P6.SetBounds(75, 3, 73, 25);
inst_P6.Caption := 'Setup each script for each player';
inst_P6.Font.Color := 2070783;
end;

procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;

procedure ShowFormModal;
begin
form_Main.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;

Coh3n

2010-12-18 18:46:50

From: Dan Cardin
The problem is that the form is going to get so unwieldy that it will be impossible to change without screwing everything up. I just tried to take out the loc viewer and now it wont compile. (one of the reasons i didn't want everything being based off of constants.)

And to get it to work, hopefully we could just use the earliest version of it. That's why I wanted to make it a separate entity from the form. If we did all the logic for the loc viewer in it's own module, you could just send it coordinates for mouse dragging. Then it would logic everything out, and return a bitmap to be displayed. Hopefully it wouldn't be too much work, but i would leave it until the form is done. Even then I would wait because I think that RM's thread where he wanted all the scripts being marked on the map could be done programatically inside the loc viewer to make it a lot more useful.

Anyways, the form code is too long now as it is. If i can get the loc viewer out, im gonna try to put the previous/next/name things into arrays. You could then create it all at once.

Honestly, don't worry about changing anything right now. Wait until I've finished everything. There's so many separate things right now that, like you said, changing one thing could screw the whole thing up. I'm actually very close to it being completely finished; although, I don't think I'll have it done before the holidays.

Dan Cardin

2010-12-18 19:03:04

look at my edits ^.

I hope you know all the shortcomings of how it is right now (when you say that you're close), like how it doesnt update the checkboxes when you switch people and stuff like that. Not being able to edit people's names once you create them and such.

Coh3n

2010-12-18 19:16:25

From: Dan Cardin
look at my edits ^.

I hope you know all the shortcomings of how it is right now (when you say that you're close), like how it doesnt update the checkboxes when you switch people and stuff like that. Not being able to edit people's names once you create them and such.

Yeah I know. :p

And shit, I wish you didn't do that. :o I've made so many changes today that I can't commit what you changed. Sorry. :(

Also, yeah all that stuff should be in arrays. What I've been working on today is the Script Setup tab and I've done all that in arrays. The rest we should just leave as is since it's working, unless you want to take on the task of converting everything in to arrays. :p

E: On the background panel, I think it's just you. ;) I think we could load the form before srl/msi, but we'd have to include Globals.simba first, since the form relies on it to set the player's information. Why does it matter which is loaded first anyway?

E2: I've committed all my changes for today, and I wont be making any more. Try adding some new players and setting them up, tell me what you think. On the last tab, it doesn't remember what you entered when you switch players/scripts. I'm not sure why, but that is handled in script_FillComponents. Also, it doesn't yet save anything in the last tab.

Dan Cardin

2010-12-18 19:37:34

Well, the version i deleted the loc viewer on was the latest version as of when originally posted the comment, right after you said you commited a bunch. And, it should be loaded after because it takes 6 seconds to load for me with just msi, plus srl, plus the fact that it screws up simba when smart dies (which happens to me when you haven't loaded rs in a real browser). It just makes a whole lot more sense to load the form first, since you dont even know that the person will run the script after they run the form, and becasue it will be faster.

as for background panel: how can you create an image that will show up on every panel, if it is only one variable? I feel like it will just reiterate over itself until the end of the loop which will be the last tab. So it will ultimately create the variable on the last tab, not any of the others.

Coh3n

2010-12-18 19:44:22

From: Dan Cardin
Well, the version i deleted the loc viewer on was the latest version as of when originally posted the comment, right after you said you commited a bunch. And, it should be loaded after because it takes 6 seconds to load for me with just msi, plus srl, plus the fact that it screws up simba when smart dies (which happens to me when you haven't loaded rs in a real browser). It just makes a whole lot more sense to load the form first, since you dont even know that the person will run the script after they run the form, and becasue it will be faster.

Okay, I'll look at the diff from my most recent commit and get your version committed as soon as I can.

From: Dan Cardin

as for background panel: how can you create an image that will show up on every panel, if it is only one variable? I feel like it will just reiterate over itself until the end of the loop which will be the last tab. So it will ultimately create the variable on the last tab, not any of the others.

It's drawing the same bitmap 5 times, it's not creating a new image. E: Nevermind. Lol, my mistake. When I did that I was actually surprised it worked, for the same reason you're saying. I think it's because it's drawing the bitmap on each panel. The variable isn't really relevant, all that matters is the DrawBitmap call.

E: Committed your changes. :) Thanks.

E: Also, I think if you include Globals.simba {$include_once MSI/MSI/Core/Globals.simba} in Form_Test, then call SetupSRL and SetupMSI after the form stuff it will work. Oh wait, the form calls MSI_SpellToStr and MSI_StrToSpell so that wouldn't work. If it's really that big of deal, we can create a file that includes everything to form needs, but that could make the rest of MSI unorganized having a cluster of functions in a random file.

E: I doubt that I'll be working on it anymore before the holidays (I go home for a week tomorrow), but I think the script setup tab stuff I wrote is pretty well organized. I hope it's not too difficult to follow. It's just a matter of getting that stuff working, then saving the script setup tab's stuff to the file and loading from the file. After that, there's the components I mentioned earlier that would go on the "Intro" tab. After that, it's just testing and tweaking.

Also, if you're wondering about the "Next" and "Previous" player buttons on each tab: I got frustrated with them displaying the next player's info and setting the previous player's info, so I made them invisible. If you can figure those out, great, otherwise I honestly don't think they're that necessary. They really only save one click.

E: I lied, I made a last commit with a few changes. See log for details. :)

Dan Cardin

2010-12-20 14:07:04

something couldnt be set up in globals to include the spells inside strtospell or something of the sort?

Coh3n

2010-12-21 01:36:50

From: Dan Cardin
something couldnt be set up in globals to include the spells inside strtospell or something of the sort?

The actual spell constants are there, it's the functions that aren't. I suppose forwards could be setup if absolutely necessary. I don't really see that as being a big deal.

Dan Cardin

2010-12-21 21:59:23

why do we need those functions inside the form though? to what purpose.

Coh3n

2010-12-29 18:46:38

From: Dan Cardin
why do we need those functions inside the form though? to what purpose.

They're called to properly set the MSI_Players array and since MSI doesn't have it's own type for spells (we use the one in SRL), the SpellToStr and StrToSpell functions are necessary.

E: Done! I'm now just working on getting it into MSI. :) Should be fully implemented in a day or two.

Dan Cardin

2010-12-29 23:06:51

list of stuff i would like to fix eventually (or see done)

-can't edit names. (timer is probably the only way to do it without a working onclickitem)
-make back/combobox/forward an array and all have the same procedures to do stuff.
-not loading smart/srl and hopefully msi until after the form closes.
-change buttons to images
-shorten form in general (namely making the changing of images to their hovers not stupid complicated)
-either delete form dragging or make it work
-either delete the question mark button or make it work
-try changing certain things to arrays instead of consts
-i dont understand why the >> tab doesn't work in the same way as the other tabs
-i also dont understand how the script choosing in the checkboxlists work.

that's it for now.

Coh3n

2010-12-30 00:52:03

From: Dan Cardin
list of stuff i would like to fix eventually (or see done)

-can't edit names. (timer is probably the only way to do it without a working onclickitem) I completely forgot about that. An Edit button could also be added and once clicked, the selected player's info would show in the TEdits.

-make back/combobox/forward an array and all have the same procedures to do stuff. Yeah that all should have been done in the beginning, but you know what, they all work right now, so I suggest leaving it the way it is. That being said, if you want to change them, be my guest. ;)

-not loading smart/srl and hopefully msi until after the form closes. I actually looked into this today, and it's not really possible unless we used different variables/types. Right now, throughout the form I set MSI_Players (rather than a temporary "FormPlayers". Also, some functions (from MSI) for setting the magic skill are used and the Script/Location lists are obtained from MSI_Scripts and MSI_Locations (which are set in SetupMSI). When writing most of the functionality I tried my best to make it so the form stuff is updated when MSI's global variables are updated.

-change buttons to images This isn't hard, just may be time consuming making all the bitmaps. And honestly, I don't think it's that necessary because we can't make custom ListBoxes, so they would stand out regardless.

-shorten form in general (namely making the changing of images to their hovers not stupid complicated) How would you suggest doing it? Again, I suggest leaving this one alone simply because it works. There's no sense in changing something that's working fine.

-either delete form dragging or make it work There is no code for form dragging? I got rid of it a long time ago, unless I forgot part of it.

-either delete the question mark button or make it work It does work. ;) It opens the MSI setup guide in your browser.

-try changing certain things to arrays instead of consts Like what? The constants we have now represent the indexes of arrays..

-i dont understand why the >> tab doesn't work in the same way as the other tabs It does? I'm pretty positive I committed it, but earlier today I added that tab to the panels array and it does the same animation as the rest of them.

-i also dont understand how the script choosing in the checkboxlists work. What don't you understand? You just check off the scripts you want to use for each player.

that's it for now.

Comments in red. :)

E: Oh, and there are some things that aren't committed to the repository as I've changed them while adding to MSI, but I don't think I did any major changes.

E2: I'm closing this since it's been committed. All other discussion should be here.