Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Knox

#341
holy sheet. Ingenious!

Ill get right to it, good news is now I can reuse this in other places too :)
#342
Code: ags

function btnQuickGuide_PrevPg_OnClick(GUIControl *control, MouseButton button, int iMode)
{
  if (iMode == 0)...stuff;
  else ...stuff;
}


There's no problem using the above code when I call the _OnClick manually (via a key press, for example), but when I click the actual button that has this code, how do I set iMode? Where should it be placed?

Code: ags

Called from inside a key press: btnQuickGuide_PrevPg_OnClick(btnQuickGuideVC_PrevPg, eMouseLeft, 1);


When a key is pressed, that function will always be mode 1, if the button of the gui is clicked on, it will always be mode 0.

(*I guess I could make 2 separate functions, one for the key press, one for the click, but Id rather not duplicate code).
#343
QuoteThis made me laugh, which means it was a success.

Same here...man I love the part where you call your friend and he tells you how to cause brain damage...the you got outside and see a brick on the floor...hehe, man I laughed out loud...ahh...dark humor at its best.

ps: my wife thought it was funny so I dont feel guity or anything:P
#344
If Im not mistaken, I think it might be this?

IndexOf:

Code: ags


(Formerly known as global function StrContains, which is now obsolete) 
(Formerly known as String.Contains, which is now obsolete)

String.IndexOf(string needle)

Checks to see if NEEDLE is contained within the specified string. Returns the character position of the match if it is, or -1 if it is not.
This function is not case sensitive; ie. testing "test string" for "sTRiN" would match.

Example: 

String haystack = "The haystack had a needle in it somewhere.";
int result = haystack.IndexOf("a needle");

if (result == -1) {
  Display("The string didn't contain the needle.");
}
else {
  Display("a needle was found starting at character %d in the string.", result);
}

See Also: String.EndsWith, String.StartsWith
#345
AGS Games in Production / Re: The Second Man
Sat 12/03/2011 17:49:50
wow this looks good! Love that cycle :)
#346
This made me chuckle...I guess Ive got a dark sense of humor too, hehe...
#347
Wow, so much better...how do you guys do it? Ill be able to apply your solution to many other things now aswell, since you explained it too.

Works perfect sir!

Thanx :)
#348
Hi,

Ive gotten this far, but its not very elegant, nor compact...plus I think I made a mistake in my logic somewhere because it doesnt work 100% like Im envisioning.

Basically what Im doing is I have 3 guide booklets that are gui's. The zorders are initialized as:
QuickGuide_VC.ZOrder = 10;
QuickGuide_PC.ZOrder = 9;
QuickGuide_SS.ZOrder = 8;

I dont want the ZOrders to ever be anything different than 8, 9 or 10. The highest is always 10, the lowest, always 8.

When you click on any of the gui's, that gui's zorder will become 10, the others, depending on their order amongst themselves, will get their zorder knocked down so that its logical.

Here is what I have, where could my error be (Ive attempted debugging without luck so far) and more important, how to make this shorter/more elegant?
Code: ags

  if (mouse.IsButtonDown(eMouseLeft) && gQuickGuidesGUI.Visible)
  {
    if (overGUI == gQuickGuidePC)
    {
      iPCz = gQuickGuidePC.ZOrder;
      if (iPCz != 10)
      {
        gQuickGuidePC.ZOrder = 10;
        iVCz = gQuickGuideVC.ZOrder;  
        iSSz = gQuickGuideSS.ZOrder;
        if (iVCz == 10) gQuickGuideVC.ZOrder = 9;
        else if (iVCz == 9) gQuickGuideVC.ZOrder = 8;
        else if (iSSz == 10) gQuickGuideSS.ZOrder = 9;
        else if (iSSz == 9) gQuickGuideSS.ZOrder = 8;       
      }
    }
    else if (overGUI == gQuickGuideVC)
    {
      iVCz = gQuickGuideVC.ZOrder;
      if (iVCz != 10)
      {
        gQuickGuideVC.ZOrder = 10;
        iPCz = gQuickGuidePC.ZOrder;  
        iSSz = gQuickGuideSS.ZOrder;
        if (iPCz == 10) gQuickGuidePC.ZOrder = 9;
        else if (iPCz == 9) gQuickGuidePC.ZOrder = 8;
        else if (iSSz == 10) gQuickGuideSS.ZOrder = 9;
        else if (iSSz == 9) gQuickGuideSS.ZOrder = 8;       
      }       
    }
    else if (overGUI == gQuickGuideSS)
    {
      iSSz = gQuickGuideSS.ZOrder;
      if (iSSz != 10)
      {
        gQuickGuideSS.ZOrder = 10;
        iVCz = gQuickGuideVC.ZOrder;  
        iPCz = gQuickGuidePC.ZOrder;
        if (iVCz == 10) gQuickGuideVC.ZOrder = 9;
        else if (iVCz == 9) gQuickGuideVC.ZOrder = 8;
        else if (iPCz == 10) gQuickGuidePC.ZOrder = 9;
        else if (iPCz == 9) gQuickGuidePC.ZOrder = 8;       
      }       
    }
  }
#349
oh wow, I did not know we could do that! Geeze, I was afraid I'd have to use global vars, dynamic arrays, etc...shows how noob I am! :P

You just saved me a crapload of work man...
#350
Hi,

Im running into a problem mostly due to my newbie-ness: Ive got a while loop using the number of inventory items in a certain "myInventoryWindow" window. Inside this loop, I run a script that does stuff + and eventually decides (depending on various factors) if that item "i" should be deleted from myInventoryWindow.

The problem is, if I delete an item in that window from inside the while loop, how in the crap am I supposed to update "iMyItemCount" so that it diminishes its amount?

Im guessing I have to use a dynamic array?

Code: ags

//Pseudo code:

  iMyItemCount = myInventoryWindow.ItemCount;
  int i = 0;
  while (i < iMyItemCount) 
  {
        functionThatDeletesItemFromInvWindow(); //processes 1 item at a time, to see if it must be deleted
        i++;
  } 
#351
hehee!

An option box is a good idea...!
#352
ok so it seems that the Multimedia Class Scheduler Service (MMCSS) is the culprit...I tested this while having Adobe AfterEffects opened at the same time as AGS and the frame rate jumped up to 100 aswell.

What Im wondering is, windows seems to detect certain programs as multimedia, and then that MMCSS kicks in, giving better performance...

...is there a way for someone to add "something inside" compiled AGS games that gives the message to windows to use MMCSS? This way, all AGS games will automatically get that cpu boost for fps wihout having to tweak the task manager or open up media players.

http://msdn.microsoft.com/en-us/library/ms684247(v=vs.85).aspx

Quote
Multimedia Class Scheduler Service
The Multimedia Class Scheduler service (MMCSS) enables multimedia applications to ensure that their time-sensitive processing receives prioritized access to CPU resources. This service enables multimedia applications to utilize as much of the CPU as possible without denying CPU resources to lower-priority applications.

MMCSS uses information stored in the registry to identify supported tasks and determine the relative priority of threads performing these tasks. Each thread that is performing work related to a particular task calls the AvSetMmMaxThreadCharacteristics or AvSetMmThreadCharacteristics function to inform MMCSS that it is working on that task.

For an example of a program that uses MMCSS, see Exclusive-Mode Streams.

Windows Server 2003 and Windows XP/2000:  MMCSS is not available.
Registry Settings
The MMCSS settings are stored in the following registry key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile

This key contains a REG_DWORD value named SystemResponsiveness that determines the percentage of CPU resources that should be guaranteed to low-priority tasks. For example, if this value is 20, then 20% of CPU resources are reserved for low-priority tasks. Note that values that are not evenly divisible by 10 are rounded up to the nearest multiple of 10. A value of 0 is also treated as 10.

The key also contains a subkey named Tasks that contains the list of tasks. By default, Windows supports the following tasks:

•Audio
•Capture
•Distribution
•Games
•Playback
•Pro Audio
•Window Manager
OEMs can add additional tasks as required.

Each task key contains the following set of values that represent characteristics to be applied to threads that are associated with the task.

Thread Priorities
The MMCSS boosts the priority of threads that are working on high-priority multimedia tasks.


MMCSS determines the priority of a thread using the following factors:

•The base priority of the task.
•The Priority parameter of the AvSetMmThreadPriority function.
•Whether the application is in the foreground.
•How much CPU time is being consumed by the threads in each category.
MMCSS sets the priority of client threads depending on their scheduling category.


#353
You're probably right, that mouse problem should have priority over the additional full-screen feature...although it might seem to be quicker (?) to add that new full-screen feature? Seems it might be the same as "add screen borders", but without expanding the game window (it would add top, down and side-borders on a 1:1 game window)...am I right to assume that (I dont know the inner workings of such things).
#354
Hi,

I was wondering if this is possible in AGS...and what can I do to get there?

Instead of giving the option of having the game fullscreen (resize/stretch), Id rather "fullscreen" mode means (for my game) that  the screensize of the game stays at 100% of its resolution, but that the background behind the game gets filled completly in black...

So basically it looks exactly like windowed mode, only you no longer see your desktop.

(The main reason I ask this is because I find fullscreen the mouse doesnt work very well and no solution seems to be in the works, and Im not a fan of the black borders nor blowing up pixels...)
#355
ooooh...nice! It works, thanx guys for all your help, (once again) ;D

Next round of beers on me.
#356
Wow, well Im gonna have to reread that 5 times! hehe...thanx for the explanations too, its appreciated.

Ok, gonna go try that out now!
#357
@ Kweepa: ok Ill investigate that (not a laptop, tested on my work + home cpu's, both win7 x64)

@Zyndikate : thnx for the link, I'll check it out!

**EDIT**

Here is Zyndikate's article:
Quote
A Windows Media Player Trick

This pertains mainly to load times, but you may see an increase in FPS as well. Next time you run Counter-strike 1.6 or Source try leaving Windows media player idly running in the background (obviously not playing any songs). Apparently Windows Media Player will speed up the performance of your computer due to a service that it uses called, “Multimedia Class Scheduler Service”.

This article on wikipedia explains this service and what it does to help you gain performance. Here is a quick excerpt from the article:

“Multimedia Class Scheduler Service (MMCSS) is a Windows service that boosts the CPU as well as I/O priority of a thread. It allows an application to get prioritized access to CPU for time-sensitive processing (such as multimedia applications) as well as prioritized disc access to ensure that the process is not starved of data to process. The MMCSS service monitors the CPU load and dynamically adjusts priority so that the application can use as much CPU time as possible without denying CPU to lower priority applications.”

So from the sounds of it, any of you that have already tweaked steam to run in low processor affinity through this tweak guide, may see almost no performance gain. Still, it’s worth a shot? Post comments if you noticed a difference in speed.


#358
Hey Mooo0onkey!

That's exactly what I was looking for, dynamic arrays...Ill go look it up in my for dummies book.

I'll go try that out as soon as Ive got access to the cpu, hope I can get it to "veurk".

Thnx
;D
#359
crap well in this case it wouldnt save me space cause it would end up being something like this:
Methinks I have no choice but to duplicate lines in this function.

Code: ags

while (j < iConstantNum)
{
  if (this == iUseItemsA)
  { 
    if (aArrayA[j].GetProperty("CustomPropertyA") == false)
    {
      ...do stuff with arrayA...
    }

  }
  else if (this == iUseItemsB)
  {
    if (aArrayB[j].GetProperty("CustomPropertyB") == false)
    {
      ...do exact same stuff as above but with arrayB 
    }
  }
}
#360
If you look at the third block of code,  Ive got a line "if (aVariableArray[j].GetProperty("CustomPropertyA") == false)".

Im always getting an error with the "aVariableArray[j]" line in the 3rd block...mainly because I dont understand how to
use an certain array depending on another value (does that make sense?);

Im trying to get "aVariableArray" to be set to either aArrayA[] or aArrayB[], depending on which of these is called: iUseItemA or iUseItemsB.

Code: ags

//(in .ash):
#define SL_A_ITEMS 6
import InventoryItem* aArrayA[SL_A_ITEMS];

#define SL_B_ITEMS 6
import InventoryItem* aArrayB[SL_B_ITEMS];


Code: ags

//(in .asc):
InventoryItem* aArrayA[SL_A_ITEMS];
InventoryItem* aArrayB[SL_B_ITEMS];

void ItemLists()
{
  aArrayA[0] = iMic; aArrayA[1] = iRadio; aArrayA[2] = iBattery; aArrayA[3] = iKeysA; aArrayA[4] = iGun; aArrayA[5] = iPatrolClip;
  aArrayB[0] = iSpray; aArrayB[1] = iMints; aArrayB[2] = iMeds; aArrayB[3] = iShield; aArrayB[4] = iMask; aArrayB[5] = iSanitizer;
}


Code: ags
 
//in some function:
{
  if (this == iUseItemsA) aVariableArray[j] = aArrayA[];
  else if (this == iUseItemsB) aVariableArray[j] = aArrayB[];
  
  if (bEx == false)
  {  
    j = 0;
    while (j < iConstantNum)
    {
      if (aVariableArray[j].GetProperty("CustomPropertyA") == false)
      {
      ...blah etc...


If I did it "straight-up" without that variable, I would just do this and it works (but its not what I want cause I dont want to write all that code twice, or more, depending on how many arrays I might create in the future):

Code: ags

//pseudo code **EDIT**
    while (j < iConstantNum)
    {
      if (blah)
      {
        if (aArrayA[j].GetProperty("CustomPropertyA") == false)
        {
          ...stuff
        }
      }
    }
      
      
    OR:
      
    while (j < iConstantNum)
    {
       if (blah)
       {
         if (aArrayB[j].GetProperty("CustomPropertyB") == false)
         {
           ...stuff
         }
       }
    }
SMF spam blocked by CleanTalk