Ejemplo n.º 1
0
/* *** SCRIPT SYMBOL: [File] File::ReadStringBack^0 *** */
static const char* File_ReadStringBack(sc_File *fil) {
  check_valid_file_handle(fil->handle, "File.ReadStringBack");
  if (feof(fil->handle)) {
    return CreateNewScriptString("");
  }

  int lle = getw(fil->handle);
  if ((lle >= 20000) || (lle < 1))
    quit("!File.ReadStringBack: file was not written by WriteString");

  char *retVal = (char*)malloc(lle);
  fread(retVal, lle, 1, fil->handle);

  return CreateNewScriptString(retVal, false);
}
Ejemplo n.º 2
0
/* *** SCRIPT SYMBOL: [String] String::Replace^3 *** */
static const char* String_Replace(const char *thisString, const char *lookForText, const char *replaceWithText, bool caseSensitive)
{
  char resultBuffer[STD_BUFFER_SIZE] = "";
  int thisStringLen = (int)strlen(thisString);
  int outputSize = 0;
  for (int i = 0; i < thisStringLen; i++)
  {
    bool matchHere = false;
    if (caseSensitive)
    {
      matchHere = (strncmp(&thisString[i], lookForText, strlen(lookForText)) == 0);
    }
    else
    {
      matchHere = (strnicmp(&thisString[i], lookForText, strlen(lookForText)) == 0);
    }

    if (matchHere)
    {
      strcpy(&resultBuffer[outputSize], replaceWithText);
      outputSize += strlen(replaceWithText);
      i += strlen(lookForText) - 1;
    }
    else
    {
      resultBuffer[outputSize] = thisString[i];
      outputSize++;
    }
  }

  resultBuffer[outputSize] = 0;

  return CreateNewScriptString(resultBuffer, true);
}
Ejemplo n.º 3
0
/* *** SCRIPT SYMBOL: [String] String::ReplaceCharAt^2 *** */
static const char* String_ReplaceCharAt(const char *thisString, int index, char newChar) {
  if ((index < 0) || (index >= (int)strlen(thisString)))
    quit("!String.ReplaceCharAt: index outside range of string");

  char *buffer = (char*)malloc(strlen(thisString) + 1);
  strcpy(buffer, thisString);
  buffer[index] = newChar;
  return CreateNewScriptString(buffer, false);
}
Ejemplo n.º 4
0
/* *** SCRIPT SYMBOL: [String] String::Format^101 *** */
static const char* String_Format(const char *texx, ...) {
  char displbuf[STD_BUFFER_SIZE];

  va_list ap;
  va_start(ap,texx);
  my_sprintf(displbuf, get_translation(texx), ap);
  va_end(ap);

  return CreateNewScriptString(displbuf);
}
Ejemplo n.º 5
0
/* *** SCRIPT SYMBOL: [String] String::Substring^2 *** */
static const char* String_Substring(const char *thisString, int index, int length) {
  if (length < 0)
    quit("!String.Substring: invalid length");
  if ((index < 0) || (index > (int)strlen(thisString)))
    quit("!String.Substring: invalid index");

  char *buffer = (char*)malloc(length + 1);
  strncpy(buffer, &thisString[index], length);
  buffer[length] = 0;
  return CreateNewScriptString(buffer, false);
}
Ejemplo n.º 6
0
/* *** SCRIPT SYMBOL: [String] String::Truncate^1 *** */
static const char* String_Truncate(const char *thisString, int length) {
  if (length < 0)
    quit("!String.Truncate: invalid length");

  if (length >= (int)strlen(thisString))
    return thisString;

  char *buffer = (char*)malloc(length + 1);
  strncpy(buffer, thisString, length);
  buffer[length] = 0;
  return CreateNewScriptString(buffer, false);
}
Ejemplo n.º 7
0
const char* get_text_property_dynamic_string(CustomProperties *cprop, const char *property) {
    int idx = game.propSchema.findProperty(property);

    if (idx < 0)
        quit("!GetTextProperty: no such property found in schema. Make sure you are using the property's name, and not its description, when calling this command.");

    if (game.propSchema.propType[idx] != PROP_TYPE_STRING)
        quit("!GetTextProperty: need to use GetProperty for a non-text property");

    const char *valtemp = cprop->getPropertyValue(property);
    if (valtemp == NULL) {
        valtemp = game.propSchema.defaultValue[idx];
    }

    return CreateNewScriptString(valtemp);
}
Ejemplo n.º 8
0
const char* TextBox_GetText_New(GUITextBox *texbox) {
    return CreateNewScriptString(texbox->Text);
}
Ejemplo n.º 9
0
const char* IAGSEngine::CreateScriptString(const char *fromText) {
  return CreateNewScriptString(fromText);
}
Ejemplo n.º 10
0
void *
ScriptString::CreateString (const char *fromText)
{
  return (void *) CreateNewScriptString (fromText);
}
Ejemplo n.º 11
0
const char *System_GetVersion() {
    return CreateNewScriptString(EngineVersion.LongString);
}
Ejemplo n.º 12
0
const char* InventoryItem_GetName_New(ScriptInvItem *invitem) {
  return CreateNewScriptString(get_translation(game.invinfo[invitem->id].name));
}
Ejemplo n.º 13
0
/* *** SCRIPT SYMBOL: [ListBox] ListBox::geti_Items *** */
const char* ListBox_GetItems(GUIListBox *listbox, int index) {
  if ((index < 0) || (index >= listbox->numItems))
    quit("!ListBox.Items: invalid index specified");

  return CreateNewScriptString(listbox->items[index]);
}
Ejemplo n.º 14
0
const char* Button_GetText_New(GUIButton *butt) {
    return CreateNewScriptString(butt->text);
}
Ejemplo n.º 15
0
/* *** SCRIPT SYMBOL: [String] String::Copy^0 *** */
static const char* String_Copy(const char *srcString) {
  return CreateNewScriptString(srcString);
}
Ejemplo n.º 16
0
/* *** SCRIPT SYMBOL: [File] File::ReadRawLineBack^0 *** */
static const char* File_ReadRawLineBack(sc_File *fil) {
  char readbuffer[MAX_MAXSTRLEN + 1];
  File_ReadRawLine(fil, readbuffer);
  return CreateNewScriptString(readbuffer);
}
Ejemplo n.º 17
0
/* *** SCRIPT SYMBOL: [String] String::UpperCase^0 *** */
static const char* String_UpperCase(const char *thisString) {
  char *buffer = (char*)malloc(strlen(thisString) + 1);
  strcpy(buffer, thisString);
  strupr(buffer);
  return CreateNewScriptString(buffer, false);
}
Ejemplo n.º 18
0
/* *** SCRIPT SYMBOL: [String] String::Append^1 *** */
static const char* String_Append(const char *thisString, const char *extrabit) {
  char *buffer = (char*)malloc(strlen(thisString) + strlen(extrabit) + 1);
  strcpy(buffer, thisString);
  strcat(buffer, extrabit);
  return CreateNewScriptString(buffer, false);
}
Ejemplo n.º 19
0
/* *** SCRIPT SYMBOL: [String] String::AppendChar^1 *** */
static const char* String_AppendChar(const char *thisString, char extraOne) {
  char *buffer = (char*)malloc(strlen(thisString) + 2);
  sprintf(buffer, "%s%c", thisString, extraOne);
  return CreateNewScriptString(buffer, false);
}