Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest WME version: WME 1.9.1 (January 1st, 2010) - download

Author Topic: Problems with the vBar  (Read 3653 times)

0 Members and 1 Guest are viewing this topic.

McCoy

  • The cocido eater
  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 365
  • Spurrrrrrring
    • View Profile
    • Spur Games
Problems with the vBar
« on: June 25, 2003, 07:52:41 PM »

Has I wrote in an old post I was triying to do an options menu like this


Well, the code is finished, and it works perfectly in projectman, but it does not work in the compiled version!!! In projectman, when the window opens, the buttons put himself in a position that represents the actual volume value that the registry sais, and when you keep pressed the left mouse button over the button of a vBar, you can drag it up and down, changing the volume while you listen a sound/music to test it, and the cursor ever stay inside the button until you release the left mouse button. But in the compiled version, when you click on the button, the only thing it do correctly is playing the music/sound! it does not move nor keep the cursors inside itself. And it doesn't catch the registry value for the volume. What's the problem? Here's the code for the button of the SFX Volume vBar (the code for the other buttons is almost equal):

Code: [Select]
#include "scripts\base.inc"


var meters; //just to hold some values
var MoveButton; //if true, the button updates its position with the mouse position
self.Text = Game.GetGlobalSFXVolume(); //get the actual sfx volume value for the text of the
                                       //button
meters.ActVol = Game.GetGlobalSFXVolume(); //same for the variable
if (meters.ActVol >= 100) self.Text = "Max"; //stupid thingie
else if (meters.ActVol <= 0) self.Text = "Off";
self.Y = self.Y - meters.ActVol; //place the button at the position desired for the actual
                                 //volume value.

on "LeftClick"
{
   
    var parent = self.Parent; //reference to the window that holds the button
    MoveButton = true; //the button must update it's position
    Game.MouseY = parent.Y + self.Y + (self.Height / 2); //place the cursor in the (vertical)
                                                         //middle of the button  
    meters.MouseY = Game.MouseY; //update the mouse position info in the variable
    Game.PlaySound("interface\system\sfx.ogg",true); //play the test sound (it's good to hear
                                                     //something while you are increasing or
                                                     //decreasing the volume).
    while (MoveButton) //loop that updates the mouse position and the volume value
    {  
   
    meters.AbsoluteX = parent.X + self.X; //the absolute Y in the screen of the button.
                                         //This is needed because the button has relative
                                         //coordinates (relative to the window) and the mouse
                                         //has absolute coordinates (relative to the screen).
                                         //Or something like that.
    meters.AbsoluteY = parent.Y + self.Y; //same for X    
   
       if(meters.ActVol <= 100 && meters.ActVol >= 0) //if the button is between the desired limits
       {
     meters.oldMouseY = meters.MouseY; //save the old mouse position to get the difference
                                       //with the actual position later
 meters.MouseY = Game.MouseY; //save the actual mouse position  
 self.Y = self.Y + (meters.MouseY - meters.oldMouseY); //get the difference between the old
                                                       //position and the actual position
                                                       //and update the button pos. accordingly
                                                       //
                                                                                                               
 meters.ActVol = meters.ActVol - (meters.MouseY - meters.oldMouseY);//same for the volume value
                                                                       //(yep, pretty usefull to  
                                                                       //make a 100px vBar, no value
                                                                       //conversion needed :D)
 if (meters.ActVol < 1) self.Text = "Off"; //stupid thingie again, but I like stupidities! :P
 else if (meters.ActVol > 99) self.Text = "Max";
 else self.Text = meters.ActVol;
 
}
if(meters.ActVol > 100) //keep the mouse cursor and the button within limits
                       //(this one for the top limit)
{  
self.Y = 80;
    Game.MouseY = meters.oldMouseY;
    meters.MouseY = Game.MouseY;
meters.ActVol = 100;
}

if(meters.ActVol < 0) //same for the bottom limit
{
self.Y = 180;
    Game.MouseY = meters.oldMouseY;
    meters.MouseY = Game.MouseY;
meters.ActVol = 0;
}

//this two ifs are for keeping the mouse cursor between the lef and right sides of the button.
if (Game.MouseX > meters.AbsoluteX + self.Width - 2) Game.MouseX = meters.AbsoluteX + self.Width - 2;
if (Game.MouseX < meters.AbsoluteX + 2) Game.MouseX = meters.AbsoluteX + 2;

if (Game.MouseY != meters.AbsoluteY + (self.Height / 2)) //and this one to keep it in the
                                                        //vertical middle
    {
    Game.MouseY = meters.AbsoluteY + (self.Height / 2);
    meters.MouseY = Game.MouseY;
    }    
    Game.SetGlobalSFXVolume(meters.ActVol);
Sleep(1); //yeah, maybe too short sleep time, but, hey, this one is the only script running,
         //we're in systemexclusive

    }
     

}

on "LeftRelease" //when the mouse button is released, stop the sound and stop updating
                 //the button position
{    
    Game.StopSound();    
    MoveButton = false;
}


I know, the code is a very crappy, sorry  ::)
« Last Edit: June 25, 2003, 07:58:19 PM by McCoy »
Logged

Click here to sign my sig!

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5677
    • View Profile
    • Dead:Code Site
Re:Problems with the vBar
« Reply #1 on: June 25, 2003, 10:32:36 PM »

Now that's weird. There should't be any difference between running the game from ProjectMan and running it standalone. Are you sure you are using the latest version of wme.exe when running the compiled game?
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

McCoy

  • The cocido eater
  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 365
  • Spurrrrrrring
    • View Profile
    • Spur Games
Re:Problems with the vBar
« Reply #2 on: June 25, 2003, 11:12:11 PM »

Mhh... who wanna shoot me? I wanna die.  :-[ Yes, it was that, I was using the old version with the systemexclusive problem.

Earth eat me please!!! :-[



And the last agonic question: the SubtitlesSpeed value is not saved automatically in the registry, nope? I have to save it emanually using Game.RegWriteNumber() no?
Logged

Click here to sign my sig!

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5677
    • View Profile
    • Dead:Code Site
Re:Problems with the vBar
« Reply #3 on: June 26, 2003, 09:05:09 AM »

And the last agonic question: the SubtitlesSpeed value is not saved automatically in the registry, nope? I have to save it emanually using Game.RegWriteNumber() no?
No, it's not saved in the registry, it's stored in the saved game...
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave
 

Page created in 0.211 seconds with 22 queries.