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 - Baguettator

#221
Hi there !

Is the 3.6 version of AGS will allow to do something with the "length" of ListBox Items ? As far as I know, there is no option to "cut" the text, it always go outside the list box.

Of course, it could be perfect that AGS "remembers" the full length of the item, even if it's displayed not fully in the listbox. For scripting reasons, it could be nice ;)

Something like that is possible ?
#222
Great news about this new version !

I hope it will be soon a first 3.6 beta release :)

Good job, keep going ! ;)
#223
Hmm ok, well I found out that if the function was called in a game_start function, buttons won't have their graphic changed (why ? I don't know !). So I ran my script in the room 1, before fade in, and in a DoOnceOnly condition. Thanks Crimson, as always perfect !
#224
OK I see. But what's the number of button.Graphic if this button has no sprite ? (I mean : the button is the grey default button in the editor).


Because my script seems to not do anything. And I wrote if (button.Graphic==0) to detect buttons without any sprite.
#225
Hi there,

Little question : if I create a dynamicsprite and assign it as a graphic of a button for example. If then I write :

Code: ags
int g=mybutton.Graphic;


Which value should be g ?

Because I have in my games a lot of buttons that use the same "template" for their graphics, but as these buttons have very differents heights/widths, I prefer to create dynamicsprite for each of these buttons when the game starts instead of import a lot of images that will make the game heavier.

That's my code :

Code: ags
DynamicSprite* fondshachures[50];

function gamestart()
{
  int h[50], l[50];
  int c;
  for (int i=0 ; i<Game.GUICount ; i++)
  {
    for (int j=0 ; j<gui[i].ControlCount ; j++)
    {
      if (gui[i].Controls[j].AsButton!=null && gui[i].Controls[j].AsButton.Graphic==0)
      {
        bool v=false;
        // Check if the dynamic sprite exists with the same width/height
        for (int k=0 ; k<c ; k++)
        {
          if (gui[i].Controls[j].AsButton.Width==l[k] && gui[i].Controls[j].AsButton.Height==h[k])
          {
            v=true;
            gui[i].Controls[j].AsButton.NormalGraphic=fondshachures[k];
            k=c;
          }
        }
        
        if (v==false) // The dynamic sprite doesn't exist yet
        {
          gui[i].Controls[j].AsButton.CreerFond(c);
          h[c]=gui[i].Controls[j].AsButton.Height;
          l[c]=gui[i].Controls[j].AsButton.Width;
          c++;
        }
      }
    }
  }
}


I know that button.Graphic==0 means no sprite is assigned to that button (so it's the grey button by default). So my goal is to scan all the buttons that are grey when the game starts, and create/assign to them a dynamicsprite.
#226
Oh nice, interesting ! Thanks !

Would it be possible to remove the limit for the functions like ReadRawLine ? Also for the length of the lines in the editor ? That's why it's an obligation to use string.Append to stock long texts into a string.
#227
Worked perfectly ! Many thanks Crimson !

By interest : what's this function "do" ? How it works and for which use ?
#228
EDIT : oh ok, I managed to correct the code so it's near to perfection :)

The problem is : the function ReadRawLineBack seems to limit the reading to 199 characters.

So some long texts of the translation are cut. And strange things happen then in my file.

Why is there a limit of 199 ? Is it possible to do it another way ?
#229
Hi !

So I come back about problems with the translation file.

My game has been translated in english, but as it  has evolved a lot, I need to update the translation. Many new texts, and many of old texts have been changed (sometimes only 1 letter, but, it changed).

When I update the transcription file in the editor, if a text is different than before, it adds a new line at the end of the transcription file, and the old line is kept.

Because so many lines changed, and it would be too long to tweak it manually, I tried to create a little program with AGS to "update" the transcription file, so that it doesn't stock anymore old texts that re not used anymore.

To do that, I copy the texts of the old transcription file, paste them in a new txt file called "original".

Then I create a new transcription file, copy all the lines (so there are all the texts really used in the game actualized) and paste them in a new txt file called "nouveau".

Then I create a new txt file called "frais" where I write all the lines really used in the game (so those which are in both "nouveau" and "original", with their translation if it has been done in the past).

These txt files are placed in the savegame directory, so the program can access to them easily.

This allow me to have a fresh transcription file, with all the translation of the texts that didn't change from the earlier version, and the new texts that need now a translation. Instead of having a transcription file of thousands of lines, because texts not used are still there since several past versions...

The problem is that I'm french, and it seems to really work nice (the program, I mean), but the functions WriteRawLine support very badly the letters like À É é â etc... Also, the txt file "frais" is written by the program (made with AGS), and is saved as ANSI. It should be UTF-8  I think, because "nouveau" and "original" are both in UTF-8 (and "frais" was also in "UTF-8 before the program writes in it).

Also, it seems that there is a limit, if the text is too long, the WriteRawLine is stopped. The text is cut at the middle (somewhere I presume).

I don't know how to do with that ? It will make me gain a lot of time to get it working.

Here I compiled my program with the 3 txt files needed ("frais" is blank, the others have the needed texts).

https://drive.google.com/file/d/1WfQJnNt_yCGsRK73CyUedJWCkwxPrMbG/view?usp=sharing

Hope someone could help me !
#230
Great !

The LineSpacing can't be modified in runtime ?
#231
Hi !

I would like to know if there is any way to tweak the space between the lines of a text, for example in a label, or space bewteen the items of a listbox.

My problem is that I use some fonts that sometimes the letters are walking "one on another"...

I don't know if such parameter can be set in AGS ?
#232
Oh ! I didn't see about the "Set" !!

Yes, the game crashes during the game, the compilation worked well. But no need to explore that problem : the "Set" solution is by far the best !

If I understand well, the "set" is automatically sorted ? Or do I need to copy it in a String [] ?

That's my code I'm going to try :

Code: ags
void Tri(this ListBox*)
{
  int t=this.ItemCount;
  Set* s=Set.Create(eSorted, eCaseSensitive);
  for (int i=0 ; i<t ; i++)
  {
    if (this==ListeEquipementsColo || this==ListeEquipementsExp)
    {
      int p=this.Items[i].IndexOf(" ");
      s.Add(this.Items[i].Substring(p+1, this.Items[i].Length));
    }
    else s.Add(this.Items[i]);
  }
  String c[]=s.GetItemsAsArray();
  this.Clear();
  for (int i=0 ; i<t ; i++)
  {
    this.AddItem(c[i]);
  }
}


EDIT : this code worked perfectly, and I think I have understood very well how to manipulate Sets. Thanks a lot !
#233
OK Thanks Crimson !

I tried to make it working for strings, but it's a fail...

That's the code I tried :

Code: ags
void _swapalpha(String arr[], int p1, int p2){
  String temp = arr[p1];
  arr[p1] = arr[p2];
  arr[p2] = temp;  
}

int _partitionalpha(String arr[], int lo, int hi) {
  String pivot = arr[hi];
  int i = lo;
  int j;
  for (j = lo; j<hi; j++) {
    if(arr[j].CompareTo(pivot) < 0) {
      _swapalpha(arr, i, j);
      i = i + 1;
    }
  }
  _swapalpha(arr, i, j);  // *****
  return i;
}

void _quicksortalpha(String arr[], int lo, int hi){
  if( lo < hi) {
    int p = _partitionalpha(arr, lo, hi);  // *****
    _quicksortalpha(arr, lo, p-1);
    _quicksortalpha(arr, p+1, hi);  // *****
  }  
}

void qsortalpha(String arr[], int size) {
  _quicksortalpha(arr, 0, size-1);
}


When I use it, the game crashes and indicates the lines where I put some *****

Any idea ? I have to admit that I didn't really understand the algorythm... :(
#234
Hey there !

I come back to that thread, and I have to thank you a lot ! I  took me time to answer, sorry :)

I have another question about sorting an array : how could it be possible to sort an array of strings with alphabetical order ? I don't know how AGS could handle that...
#235
Ow.... That's true. I didn't know that I had to do that for the "Create" functions, as they were only drawing surfaces. Thanks a lot !

By the way, it's not the subject here, but I have to say that it appears in the editor some problem (or maybe not, you will tell me)  : if a function imported in a struct (this way we can use "this" related to this struct's element) is too long, the editor didn't show anymore the parameters for functions when we write "this" and then hit the "."

It's not really a big problem, but sometimes, it is annoying because you don't necessarly remember what are the parameters of the functions. Also, it doesn't display the components of the struct after the ".", after "this".

Crimson Wizard, you can have a look of that in my game, just in case of ? Go to "Struct Cartes", and at the end of the function "Cartes::CreationCartes", write something like "this.Composition()". This function has many parameters, but it is not displayed in the editor, like a help for the mind. I saw that this thing is working well at the start of the function (when the code is not too big), and until some step, it doesn't work anymore.
#236
In the module, I just wrote the "true" for preservealphachannel options, for both needles and clock, and, there the result : surprise !!

https://drive.google.com/file/d/1oJ6WQTR0Yybrgj4QDzuqUIaIhmWbUsrx/view?usp=sharing

Here the code of the module. It seems that the Drawing function is putting some pink at the edges of the image.

Code: ags
static DynamicSprite* Horloge::CreateFromSprites(int h, int m, int heure, int minute, int fond) {
  
  if ((heure < 1) || (minute < 1)) return null; // Il faut obligatoirement spécifier des sprites valides
    
  DynamicSprite* he = DynamicSprite.CreateFromExistingSprite(heure, true); // La sprite des heures
  DynamicSprite* mi = DynamicSprite.CreateFromExistingSprite(minute, true); // La sprite des minutes
  
  int taille; // Définira la taille de la sprite retournée
  
  int t_h = he.Height; // La hauteur de l'image de l'aiguille des heures
  int t_m = mi.Height; // La hauteur de l'image de l'aiguille des minutes
  
  if (t_h > t_m) taille = t_h * 2; // L'image la plus grande définit
  else taille = t_m * 2; // la taille de la sprite à retourner
  
  DynamicSprite* he2 = DynamicSprite.Create(taille, taille); // La sprite des heures centrées
  DynamicSprite* mi2 = DynamicSprite.Create(taille, taille); // La sprite des minutes centrées
  DrawingSurface* she2 = he2.GetDrawingSurface(); // Les surfaces correspondantes
  DrawingSurface* smi2 = mi2.GetDrawingSurface(); // Les surfaces correspondantes
  
  she2.DrawImage((taille - he.Width) / 2, taille / 2 - t_h, he.Graphic); // On centre
  smi2.DrawImage((taille - mi.Width) / 2, taille / 2 - t_m, mi.Graphic); // On centre
  
  she2.Release(); // On associe la surface obtenue à la sprite
  smi2.Release(); // On associe la surface obtenue à la sprite
  
  if (h < 0) h = 12 + h % 12; // On gère les valeurs négatives pour h
  if (m < 0) m = 60 + m % 60; // et pour m

  he2.Rotate( (((h % 12) * 30 + (m % 60) / 2) % 359) + 1 ); // On tourne (+1 car Rotate ne supporte pas la valeur 0)
  mi2.Rotate( (((m % 60) * 6) % 359) + 1 ); // De même, on module pour ne pas dépasser 359
  
  DynamicSprite* horl = DynamicSprite.Create(taille, taille); // La sprite que l'on retournera
  DrawingSurface* cadran = horl.GetDrawingSurface(); // Sa surface, sur laquelle on va dessiner les aiguilles
  
  if (fond > 0) { // On dessine le fond s'il en est spécifié un
    DynamicSprite* spr_fond = DynamicSprite.CreateFromExistingSprite(fond, true); // La sprite du slot fond
    cadran.DrawImage((taille - spr_fond.Width) / 2, (taille - spr_fond.Height) / 2, fond); // On centre le fond
  }
  
  cadran.DrawImage((taille - mi2.Width) / 2, (taille - mi2.Height) / 2, mi2.Graphic); // On dessine l'aiguille des minutes
  cadran.DrawImage((taille - he2.Width) / 2, (taille - he2.Height) / 2, he2.Graphic); // On dessine l'aiguille des heures
  
  cadran.Release(); // On associe la surface obtenue à la sprite
  
  return horl; // Et on retourne la sprite
  
}
#237
It's displayed in a dynamic sprite. I use a module to make a clock. From the french AGS community :

https://adventuregamestudio.1fr1.net/t1686-horloge-analogique

EDIT : it's a dynamic sprite, and this clock is drew on that dynamic sprite. Then the "needles".

#238
I really used "import alpha channel" and "leave at is", and my game is in 32-bit true color and I have activated proper alpha blending.

So it seems that the image has a problem. I insist that the pink appears only "around" the clock, not on the full background of the sprite.

Is there any problem with AGS ? Because the normal image is displayed normally in windows or any program that can open it, but it appears strangely in AGS ONLY.

By the way, how could I give to the clock a proper alpha channel ?
#239
Yeah, I know, that's just what I did !! It looks like that in game... :(
#240
Hi again !

I come with this problem that I tried to forget because it was not so important, but at least, I'm looking for a solution, and now it's a good time to find one ! :)

I use a sprite of a clock to show the time in my game, but, I can't understand why, whereas I import my sprite with an alpha channel, in PNG, there is always an ugly "purple" thing around the clock.

Here is the result "in game" :

https://drive.google.com/file/d/1dxyvfgaK_6CG_yLeAWVGRMFprnaKiRk3/view?usp=sharing

Here are two versions of my sprite, I tried with a black "contour", and it doesn't work too.

https://drive.google.com/file/d/10CtmML7eIRf4W7IMhJoXKLR6Uhbc34Kx/view?usp=sharing

https://drive.google.com/file/d/18Eu23YQomVnGP3q4ypZWT6qxwUjgAY-x/view?usp=sharing

Any idea ? The purple is like the "magic pink" used for transparent things in AGS, but I don't why it appears like that. I tried the same sprites on a magic pink background, it didn't work...
SMF spam blocked by CleanTalk