Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // main global script file
- // Globals from GUIscript
- import int ActionLabelColorHighlighted;
- import char key_l_yes, key_u_yes, key_l_no, key_u_no;
- import int action_l_keycode[A_COUNT_];
- import int action_u_keycode[A_COUNT_];
- import int GStopsaveitem;
- import int listBoxGap;
- import int lang;
- import InventoryItem*ItemGiven;
- // Door IDs in use are:
- ///////////////////////////////////////////////
- // ID 20 - Sample Door in Room 1
- ///////////////////////////////////////////////
- // =======================================================================================
- function game_start() {
- String tr_lang;
- // --- translate GUI action buttons ---
- tr_lang = GetTranslation("GUI_LANGUAGE");
- tr_lang = tr_lang.LowerCase();
- if (tr_lang == "de") {
- lang = eLangDE;
- }
- else if (tr_lang =="es") {
- lang = eLangES;
- }
- else if (tr_lang =="fr") {
- lang = eLangFR;
- }
- else if (tr_lang =="en") {
- lang = eLangEN;
- }
- else if (tr_lang =="it") {
- lang = eLangIT;
- }
- AdjustLanguage();
- // --- initialize game settings ---
- SetDefaultAction(eMA_WalkTo);
- set_double_click_speed(GetGameSpeed()/4);
- // --- set the pixel gap for listbox items according to the screen res
- if (System.ScreenWidth<640) listBoxGap = 2;
- else listBoxGap = 4;
- }
- function on_mouse_click(MouseButton button) {
- }
- function repeatedly_execute() {
- }
- function on_key_press(eKeyCode keycode) {
- // called when a key is pressed. keycode holds the key's ASCII code
- // --- PAUSE-GUI ---
- if (keycode == eKeySpace)
- {
- // SPACEBAR
- if (!IsGamePaused()) {
- PauseGame();
- AdjustGUIText();
- gPaused.Visible=true;
- }
- else {
- gPaused.Visible=false;
- UnPauseGame();
- SetAction(eMA_Default);
- ActionLine.TextColor=ActionLabelColorHighlighted;
- CheckDefaultAction();
- UpdateActionBar();
- }
- }
- // --- RESTART-GUI ---
- else if (gRestart.Visible) {
- // if exit gui is on
- if (keycode==key_u_no || keycode == key_l_no) gRestart.Visible=false; // if N is pressed continue
- if (keycode==key_u_yes || keycode == key_l_yes) RestartGame(); // if Y is pressed restart game
- }
- // --- QUITGAME-GUI ---
- if (gConfirmexit.Visible) {
- // if exit gui is on
- if (keycode==key_u_no || keycode==key_l_no) gConfirmexit.Visible=false; // if N is pressed continue
- if (keycode==key_u_yes || keycode==key_l_yes) QuitGame(0); // if Y is pressed quit game
- }
- if (IsGamePaused()) keycode = 0; // game paused, so don't react to keypresses
- // Translate GUIs on keypress
- if (keycode == eKeyF5 || keycode == eKeyF6 || keycode == eKeyF8 || keycode == eKeyCtrlC) AdjustGUIText();
- //
- if (keycode == eKeyF5) gOptions.Visible=true; // F5 - OPTIONS
- if (keycode == eKeyF8) gRestart.Visible=true; // F8 - RESTART
- if (keycode == eKeyCtrlC) gConfirmexit.Visible=true; // Ctrl-C - QUIT
- 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
- // --- triggering actions by the keys:---
- int act_i=0;
- while (act_i<A_COUNT_) {
- if (keycode == action_l_keycode[act_i] || keycode==action_u_keycode[act_i]) {
- SetAction(act_i);
- act_i=A_COUNT_;
- }
- else {
- act_i++;
- }
- }
- }
- function on_event(EventType event, int data) {
- if (event==eEventLeaveRoom)
- if (event==eEventRestoreGame) {
- AdjustLanguage();
- }
- if (event==eEventEnterRoomBeforeFadein || event==eEventRestoreGame)
- player.PlaceOnWalkableArea();
- }
- ////////////////////////////////////////////////////////////////////////////////////
- // GUI handling
- ////////////////////////////////////////////////////////////////////////////////////
- function Action_Click(GUIControl *control, MouseButton button) {
- Action tempbutton = getButtonAction(control.ID);
- SetAction(tempbutton);
- }
- function btnMainOpt_OnClick(GUIControl *control, MouseButton button)
- {
- AdjustGUIText();
- gOptions.Visible=true;
- }
- function ScrollInv_Click(GUIControl *control, MouseButton button) {
- if (control==InvUp) MainInv.ScrollUp();
- else MainInv.ScrollDown();
- }
- function Options_Click(GUIControl *control, MouseButton button) {
- if (control==OptionsSave) {
- //save game
- gOptions.Visible=false;
- GetLucasSavegameListBox(SaveListBox);
- gSave.Visible=true;
- }
- if (control==OptionsLoad) {
- //load game
- gOptions.Visible=false;
- GetLucasSavegameListBox(RestoreListBox);
- RestoreListBox.TopItem=0;
- gRestore.Visible=true;
- }
- if (control==OptionsPlay) {
- // continue playing
- gOptions.Visible=false;
- }
- if (control==OptionsQuit) {
- // exit??
- gOptions.Visible=false;
- gConfirmexit.Visible=true;
- }
- }
- function OptionsRestart_OnClick(GUIControl *control, MouseButton button)
- {
- gOptions.Visible=false;
- gRestart.Visible=true;
- }
- function OptionsDefault_OnClick(GUIControl *control, MouseButton button)
- {
- OptionsSldMusic.Value = 80;
- OptionsSldSound.Value = 90;
- OptionsSldSpeed.Value = 40;
- #ifver 3.2
- Game.SetAudioTypeVolume(eAudioTypeMusic, OptionsSldMusic.Value, eVolExistingAndFuture);
- Game.SetAudioTypeVolume(eAudioTypeSound, OptionsSldSound.Value, eVolExistingAndFuture);
- Game.SetAudioTypeVolume(eAudioTypeAmbientSound, OptionsSldSound.Value, eVolExistingAndFuture);
- #endif
- #ifnver 3.2
- SetSoundVolume(OptionsSldSound.Value);
- SetMusicVolume(OptionsSldMusic.Value);
- #endif
- SetGameSpeed(OptionsSldSpeed.Value);
- }
- function OptionsSldMusic_OnChange(GUIControl *control)
- {
- #ifver 3.2
- Game.SetAudioTypeVolume(eAudioTypeMusic, OptionsSldMusic.Value, eVolExistingAndFuture);
- #endif
- #ifnver 3.2
- SetMusicVolume(OptionsSldMusic.Value);
- #endif
- }
- function OptionsSldSound_OnChange(GUIControl *control)
- {
- #ifver 3.2
- Game.SetAudioTypeVolume(eAudioTypeSound, OptionsSldSound.Value, eVolExistingAndFuture);
- Game.SetAudioTypeVolume(eAudioTypeAmbientSound, OptionsSldSound.Value, eVolExistingAndFuture);
- #endif
- #ifnver 3.2
- SetSoundVolume(OptionsSldSound.Value);
- #endif
- }
- function OptionsSldSpeed_OnChange(GUIControl *control)
- {
- SetGameSpeed(OptionsSldSpeed.Value);
- }
- function Restore_Click(GUIControl *control, MouseButton button) {
- if (control==RestoreCancel) gRestore.Visible=false;
- if (control==RestoreScrollUp) {
- if (GStopsaveitem < 5) GStopsaveitem = 0;
- else GStopsaveitem -= 5;
- RestoreListBox.TopItem=GStopsaveitem;
- }
- if (control==RestoreScrollDown) {
- if (GStopsaveitem < 90) {
- GStopsaveitem += 5;
- RestoreListBox.TopItem=GStopsaveitem;
- }
- }
- }
- function RestoreListBox_Click(GUIControl *control) {
- int index = RestoreListBox.SelectedIndex;
- String buffer=Game.GetSaveSlotDescription(index+100);
- if (buffer!=null) {
- gRestore.Visible=false;
- RestoreGameSlot(index + 100);
- }
- }
- function Save_Click(GUIControl *control, MouseButton button) {
- int index = SaveListBox.SelectedIndex;
- String buffer;
- if (control==SaveCancel) {
- gSave.Visible=false;
- gSavetextbox.Visible=false;
- }
- if (control==SaveOK && index >= 0) {
- buffer=SaveTextBox.Text;
- gSave.Visible=false;
- gSavetextbox.Visible=false;
- SaveGameSlot (index + 100, buffer);
- }
- if (control==SaveScrollUp) {
- gSavetextbox.Visible=false;
- SaveListBox.SelectedIndex=-1;
- if (GStopsaveitem < 5) GStopsaveitem = 0;
- else GStopsaveitem -= 5;
- SaveListBox.TopItem=GStopsaveitem;
- }
- if (control==SaveScrollDown && GStopsaveitem < 90) {
- gSavetextbox.Visible=false;
- SaveListBox.SelectedIndex=-1;
- GStopsaveitem += 5;
- SaveListBox.TopItem=GStopsaveitem;
- }
- }
- function SaveListBox_Click(GUIControl *control) {
- int saveBox_ypos;
- int saveBox_xpos;
- int index = SaveListBox.SelectedIndex;
- String buffer=String.Format("%d.", index+1);
- SaveLabel.Text=buffer;
- buffer=Game.GetSaveSlotDescription(index+100);
- if (buffer==null) buffer="";
- SaveTextBox.Text=buffer;
- saveBox_ypos = gSave.Y + SaveListBox.Y + ((index - GStopsaveitem) * (GetTextHeight(SaveLabel.Text, SaveLabel.Font, SaveLabel.Width)+listBoxGap));
- saveBox_xpos = GetTextWidth(SaveLabel.Text, SaveLabel.Font);
- SaveTextBox.SetPosition(saveBox_xpos, 0);
- gSavetextbox.SetPosition(gSave.X + SaveListBox.X, saveBox_ypos);
- gSavetextbox.Visible=true;
- }
- function SaveTextBox_Click(GUIControl *control) {
- if (mouse.IsButtonDown(eMouseRight)) gSavetextbox.Visible=false;
- }
- function dialog_request(int param) {
- }
- //////////////////////////////////////////////////////////////////////////
- ///////////////////Custom FUNCTIONS//////////////////////////////////
- //////////////////////////////////////////////////////////////////////////
- /* Character, Object, Hotspot full blown SAMPLE
- function cChar_AnyClick() {
- // TALK TO (characters only)
- if (UsedAction(eGA_TalkTo)) {
- Unhandled();
- }
- // LOOK AT
- else if(UsedAction(eGA_LookAt)) {
- Unhandled();
- }
- // OPEN
- else if(UsedAction(eGA_Open)) {
- Unhandled();
- }
- // CLOSE
- else if(UsedAction(eGA_Close)) {
- Unhandled();
- }
- // USE
- else if(UsedAction(eGA_Use)) {
- Unhandled();
- }
- // Push
- else if(UsedAction(eGA_Push)) {
- Unhandled();
- }
- // Pull
- else if(UsedAction(eGA_Pull)) {
- Unhandled();
- }
- // PICKUP
- else if(UsedAction(eGA_PickUp)) {
- Unhandled();
- }
- // GIVE TO (characters only)
- else if(UsedAction(eGA_GiveTo)) {
- Unhandled();
- }
- //USE INV
- else if(UsedAction(eGA_UseInv)) {
- Unhandled();
- }
- else Unhandled();
- }
- */
- /* Inventory SAMPLE
- // LOOK AT
- else if(UsedAction(eGA_LookAt)) {
- Unhandled();
- }
- // USE
- else if(UsedAction(eGA_Use)) {
- Unhandled();
- }
- // Push
- else if(UsedAction(eGA_Push)) {
- Unhandled();
- }
- // Pull
- else if(UsedAction(eGA_Pull)) {
- Unhandled();
- }
- //USE INV
- else if(UsedAction(eGA_UseInv)) {
- Unhandled();
- }
- else Unhandled();
- */
- function iBook_AnyClick()
- {
- if (UsedAction(eGA_LookAt)) {
- dBook.Start();
- }
- }
- function iSheet_AnyClick()
- {
- if (UsedAction(eGA_LookAt)) {
- cRachel.Say("It's my bedsheet.");
- }
- if (UsedAction(eGA_UseInv)) {
- if (cRachel.ActiveInventory == iPants) {
- cRachel.AddInventory(iSPTT);
- cRachel.LoseInventory(iSheet);
- cRachel.LoseInventory(iPants);
- cRachel.Say("I tied my sheet and pants together. It looks like a rope now.");
- }
- if (cRachel.ActiveInventory == iShirt) {
- cRachel.AddInventory(iSSTT);
- cRachel.LoseInventory(iSheet);
- cRachel.LoseInventory(iShirt);
- cRachel.Say("It tied my sheet and shirt together. It looks like a rope now.");
- }
- if (cRachel.ActiveInventory == iShPTT) {
- cRachel.AddInventory(iSTTL);
- cRachel.LoseInventory(iSheet);
- cRachel.LoseInventory(iShPTT);
- cRachel.Say("I tied my sheet to the shirt and pants making an even longer clothing rope.");
- }
- }
- }
- function iPants_AnyClick()
- {
- Display("iPants_AnyClick");
- if (UsedAction(eGA_LookAt)) {
- cRachel.Say("It's my pants.");
- }
- if (UsedAction(eGA_UseInv)) {
- if (cRachel.ActiveInventory == iSheet) {
- cRachel.AddInventory(iSPTT);
- cRachel.LoseInventory(iSheet);
- cRachel.LoseInventory(iPants);
- cRachel.Say("I tied my sheet and pants together. It looks like a rope now.");
- }
- if (cRachel.ActiveInventory == iShirt) {
- cRachel.AddInventory(iShPTT);
- cRachel.LoseInventory(iShirt);
- cRachel.LoseInventory(iPants);
- cRachel.Say("I tied my shirt and pants together. It looks like a rope now.");
- }
- if (cRachel.ActiveInventory == iSSTT) {
- cRachel.AddInventory(iSTTL);
- cRachel.LoseInventory(iPants);
- cRachel.LoseInventory(iSSTT);
- cRachel.Say("I tied my pants to the sheet and shirt making an even longer clothing rope.");
- }
- }
- }
- function iShirt_AnyClick()
- {
- if (UsedAction(eGA_LookAt)) {
- cRachel.Say("It's my smilely face shirt");
- }
- if (UsedAction(eGA_UseInv)) {
- if (cRachel.ActiveInventory == iSheet) {
- cRachel.AddInventory(iSSTT);
- cRachel.LoseInventory(iSheet);
- cRachel.LoseInventory(iShirt);
- cRachel.Say("It tied my sheet and shirt together. It looks like a rope now.");
- }
- if (cRachel.ActiveInventory == iPants) {
- cRachel.AddInventory(iShPTT);
- cRachel.LoseInventory(iShirt);
- cRachel.LoseInventory(iPants);
- cRachel.Say("I tied my shirt and pants together. It looks like a rope now.");
- }
- if (cRachel.ActiveInventory == iSPTT) {
- cRachel.AddInventory(iSTTL);
- cRachel.LoseInventory(iShirt);
- cRachel.LoseInventory(iSPTT);
- cRachel.Say("I tied my shirt to the sheet and pants making an even longer clothing rope.");
- }
- }
- }
- function iSock_AnyClick()
- {
- if (UsedAction(eGA_LookAt)) {
- cRachel.Say("It's my annoyingly pink giant sock.");
- }
- }
- function iSPTT_AnyClick()
- {
- if (UsedAction(eGA_LookAt)) {
- cRachel.Say("I tied my sheet and pants together. It looks like a rope now.");
- }
- if (UsedAction(eGA_UseInv)) {
- if (cRachel.ActiveInventory == iShirt) {
- cRachel.AddInventory(iSTTL);
- cRachel.LoseInventory(iShirt);
- cRachel.LoseInventory(iSPTT);
- cRachel.Say("I tied my shirt to the sheet and pants making an even longer clothing rope.");
- }
- }
- }
- function iSSTT_AnyClick()
- {
- if (UsedAction(eGA_LookAt)) {
- cRachel.Say("I tied my sheet and shirt together. It looks like a rope now.");
- }
- if (UsedAction(eGA_UseInv)) {
- if (cRachel.ActiveInventory == iPants) {
- cRachel.AddInventory(iSTTL);
- cRachel.LoseInventory(iPants);
- cRachel.LoseInventory(iSSTT);
- cRachel.Say("I tied my pants to the sheet and shirt making an even longer clothing rope.");
- }
- }
- }
- function iShPTT_AnyClick()
- {
- if (UsedAction(eGA_LookAt)) {
- cRachel.Say("I tied my shirt and pants together. It looks like a rope now.");
- }
- if (UsedAction(eGA_UseInv)) {
- if (cRachel.ActiveInventory == iSheet) {
- cRachel.AddInventory(iSTTL);
- cRachel.LoseInventory(iSheet);
- cRachel.LoseInventory(iShPTT);
- cRachel.Say("I tied my sheet to the shirt and pants making an even longer clothing rope.");
- }
- }
- }
- function iSTTL_AnyClick()
- {
- if(UsedAction(eGA_LookAt)) {
- cRachel.Say("I tied a bunch of laundry into a long rope.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment