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.