Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Object* curObj;
- int prevX, prevY;
- function GetCursorObject()
- {
- int x, y;
- int type;
- String name;
- // check object under cursor
- x = mouse.x; y = mouse.y;
- type = GetLocationType(x, y);
- name = Game.GetLocationName(x, y);
- // change cursor mode
- if (type != eLocationNothing) {
- if (type == eLocationCharacter) mouse.Mode = eModeTalkto;
- if (type == eLocationHotspot) mouse.Mode = eModeLookat; //mouse.Mode = eModeInteract;
- if (type == eLocationObject) {
- curObj = Object.GetAtScreenXY(x, y);
- if (curObj.GetProperty("active")) mouse.Mode = eModePickup; else mouse.Mode = eModePointer;
- }
- nameObj.Text = name;
- } else {
- mouse.Mode = eModePointer;
- nameObj.Text = "";
- }
- }
- // called when the game starts, before the first room is loaded
- function game_start()
- {
- }
- GUI * movingGUI;
- int guiX, guiY;
- function on_event(EventType event, int data)
- {
- if (event == eEventGUIMouseUp) {
- //debuginfo.Text = "mouseUp";
- movingGUI = null;
- }
- }
- /*
- function unhandled_event(int what, int type)
- {
- if (what == 2 && type == 5) debuginfo.Text = "pickup";
- }
- */
- // put anything you want to happen every game cycle in here
- function repeatedly_execute()
- {
- if (mouse.Visible) GetCursorObject();
- // moving windows
- if (movingGUI != null) {
- movingGUI.X += mouse.x - prevX;
- movingGUI.Y += mouse.y - prevY;
- }
- prevX = mouse.x; prevY = mouse.y;
- // inventory
- if (mouse.y > inventoryGui.Y) {
- if (player.ActiveInventory == null) {
- //mouse.Mode = eModeUseinv;
- mouse.Mode = eModeInteract;
- //mouse.Mode = eModePickup;
- //debuginfo.Text = "YES";
- }
- } else {
- //if (mouse.Mode == eModeInteract) {
- //debuginfo.Text = "NO";
- mouse.Mode = eModePointer;
- //}
- }
- }
- function iInvBook_Interact()
- {
- debuginfo.Text = "NO";
- player.ActiveInventory = iInvBook1;
- }
- // put here anything you want to happen every game cycle, even when the game is blocked
- function repeatedly_execute_always()
- {
- }
- // called when a key is pressed. keycode holds the key's ASCII code
- function on_key_press(eKeyCode keycode)
- {
- if (keycode == eKeyP) { if (IsGamePaused() == 1) UnPauseGame(); else PauseGame(); }
- if (IsGamePaused()) keycode = 0;
- //
- if (keycode == eKeyCtrlQ) QuitGame(1); // Ctrl-Q
- if (keycode == eKeyF9) RestartGame(); // F9
- if (keycode == eKeyF12) SaveScreenShot("scrnshot.pcx"); // F12
- if (keycode == eKeyCtrlS) Debug(0,0); // Ctrl-S, give all inventory
- if (keycode == eKeyCtrlV) Debug(1,0); // Ctrl-V, version
- if (keycode == eKeyCtrlA) Debug(2,0); // Ctrl-A, show walkable areas
- if (keycode == eKeyCtrlX) Debug(3,0); // Ctrl-X, teleport to room
- //
- if (keycode == eKey1) Game.ChangeTranslation("english");
- if (keycode == eKey2) Game.ChangeTranslation("russian");
- }
- function MouseClick()
- {
- isMouse = true;
- //debuginfo.Text = "YesMouse";
- //ProcessClick(mouse.x, mouse.y, eModeWalkto);
- if (mouse.Mode == eModePointer) ProcessClick(mouse.x, mouse.y, eModeWalkto);
- else ProcessClick(mouse.x, mouse.y, mouse.Mode);
- }
- function on_mouse_click(MouseButton button) // called when a mouse button is clicked. button is either LEFT or RIGHT
- {
- if (IsGamePaused() == 1) { }
- else if (button == eMouseLeft)
- {
- MouseClick();
- }
- else // right-click, so cycle cursor
- {
- ProcessClick(mouse.x, mouse.y, eModeLookat);
- //ProcessClick(mouse.x, mouse.y, eModeInteract);
- }
- //
- if (button == eMouseLeftInv) {
- //player.ActiveInventory = Game.inv_activated;
- //player.ActiveInventory =
- debuginfo.Text = "123";
- }
- }
- // DIALOGS
- function dialog_request(int param) {
- }
- /*
- function OpenDoor(int index)
- {
- RestoreWalkableArea(10+index);
- object[5+index].Graphic = 164;
- }
- */
- // GUI computer
- // Message Box
- function SwitchAllGUI(GUI *except, bool on)
- {
- int i = 0;
- while (i < 10) {
- if (gui[i] != null) {
- if (gui[i] != except) gui[i].Clickable = on;
- }
- i++;
- }
- }
- function MessageBox(String caption, String text)
- {
- SwitchAllGUI(message, false);
- messageCaption.Text = caption;
- messageText.Text = text;
- message.X = screen.Width / 2;
- message.Y = screen.Height / 2;
- message.Visible = true;
- }
- // files
- function File1_OnClick(GUIControl *control, MouseButton button)
- {
- viewer1.Visible = true;
- }
- function File2_OnClick(GUIControl *control, MouseButton button)
- {
- viewer2.Visible = true;
- }
- function File3_OnClick(GUIControl *control, MouseButton button)
- {
- viewer3.Visible = true;
- }
- String savedText;
- function FileSaved_OnClick(GUIControl *control, MouseButton button)
- {
- edit.Text = savedText;
- notepad.Visible = true;
- }
- // viewer
- function viewer_OnClick(GUI *theGui, MouseButton button)
- {
- movingGUI = theGui;
- }
- function ViewerClose_OnClick(GUIControl *control, MouseButton button)
- {
- control.OwningGUI.Visible = false;
- }
- // notepad
- function notepadIcon_OnClick(GUIControl *control, MouseButton button)
- {
- edit.Text = "";
- notepad.Visible = true;
- }
- function SaveFile_OnClick(GUIControl *control, MouseButton button)
- {
- savedText = edit.Text;
- //Display("File saved in 'saved.txt'");
- MessageBox("notepad", "File saved in 'saved.txt'");
- FileSaved.Visible = true;
- }
- function NotepadClose_OnClick(GUIControl *control, MouseButton button)
- {
- notepad.Visible = false;
- }
- // message
- function messageButton_OnClick(GUIControl *control, MouseButton button)
- {
- SwitchAllGUI(message, true);
- message.Visible = false;
- }
- function messageClose_OnClick(GUIControl *control, MouseButton button)
- {
- SwitchAllGUI(message, true);
- message.Visible = false;
- }
- // password
- function archive_OnClick(GUIControl *control, MouseButton button)
- {
- password.X = (screen.Width - password.Width) / 2;
- password.Y = (screen.Height - password.Height) / 2;
- passwordEdit.Text = "*****";
- password.Visible = true;
- }
- function Extract() {
- }
- function passwordOK_OnClick(GUIControl *control, MouseButton button)
- {
- if (passwordEdit.Text == correctPassword) {
- password.Visible = false;
- MessageBox("Extracting...", "Complete successful");
- Extract();
- } else {
- password.Visible = false;
- MessageBox("Extracting...", "Password incorrect");
- }
- }
- function passwordClose_OnClick(GUIControl *control, MouseButton button)
- {
- password.Visible = false;
- }
- // folder
- function FolderOpen_OnClick(GUIControl *control, MouseButton button)
- {
- folder.X = 60;
- folder.Y = 30;
- folder.Visible = true;
- }
- function FolderClose_OnClick(GUIControl *control, MouseButton button)
- {
- folder.Visible = false;
- }
- /*
- GUI *theGui = GUI.GetAtScreenXY(mouse.x, mouse.y);
- if (theGui != null) debuginfo.Text = String.Format("%d", theGui.ID);
- */
- // back
- function backButton_OnClick(GUIControl *control, MouseButton button)
- {
- player.ChangeRoom(4, 0, 0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement