Перейти к содержанию

Дайджесты за январь-февраль

Обновления гайдов и аддонов

Январь Февраль

Мониторинг серверов и редактор аддонов

Представляем вам две легенды. То, о чем можно было только мечтать, стало реальностью.

Мониторинг серверов Редактор аддонов

Подсказки из игры на вашем сайте

Теперь вы можете отображать сведения о внутриигровых элементах простым наведением курсора мыши.

Подробнее

Апдейтер аддонов

Представляем вам программу для автообновления аддонов и делимся подробностями.

Подробнее Скачать

We can made WString functions


Гость Tycere

Рекомендуемые сообщения

I have looked in the last weekend in the moddingdocuments for 2.0.9 (i think its the same like 2.0.8) and 3.0. I have found new functions for the EditLine. There are InsertTextAtCursorPos, DeleteCharAtCursorPos and BackspaceCharAtCursorPos. I tested it now on the russian client (3.0.00. 25), it works.

I created a function substring and an other named concat. With substring you can get a part of a given WString. With concat you can merge WStrings.

I create a copy of an existing EditLine, for example the ChatInput and use it for the functions. I tested it with an own EditLine, but i noticed that the TextStyle "multiline" is not working. Tabulator is also not working. I think the reason is the standard TextFilter on it.

Code:
-- ChatInput/ChatInput/Field/Input

local copyEditLine = mainForm:CreateWidgetByDesc(

stateMainForm:GetChildChecked("ChatInput", false)

:GetChildChecked("ChatInput", false)

:GetChildChecked("Field", false)

:GetChildChecked("Input", false)

:GetWidgetDesc())

copyEditLine:Show(false)

--- s: WString - The text that will be used for substring

--- index: number - The start index of the text

--- length: number - The maximum length of the result

--- example: Substring(userMods.ToWString("Hello World"), 6, 5)

---          This returns a WString like userMods.ToWString("World")

---          Substring(userMods.ToWString("Hello World"), 0, 5)

---          This returns a WString like userMods.ToWString("Hello")

function Substring(s, index, length)

  -- check input parameters

  if not s and not command.IsWString(s) then

    return nil

  end

  if index < 0 then

    index = 0

  end

  if length < 1 then

    return common.GetEmptyWString()

  end

  -- set the text to the copied editline

  copyEditLine:SetText(s)

  -- get the length of the given text

  local slength = copyEditLine:GetPosObjectCount()

  -- calculate resulting string size

  local resultLength = slength - index

  if resultLength > length then

    resultLength = length

  end

  -- if resultLength smaller than 1, give empty wstring

  if resultLength < 1 then

    return common.GetEmptyWString()

  end

  -- set position of copiesEditLine to begin

  copyEditLine:SetCursorPos(0)

  -- delete chars

  for i = 0, index-1 do

    copyEditLine:DeleteCharAtCursorPos()

  end

  -- calculate amount of chars to be deleted at the end of the text

  local charsToDelete = slength - index - resultLength

  -- set position to the length, then we can delete all chars at the end

  copyEditLine:SetCursorPos(resultLength) 

  for i = 0, charsToDelete-1 do

    copyEditLine:DeleteCharAtCursorPos()

  end

  return copyEditLine:GetText()

end

--- merging an array of wstring to one wstring

--- example: Concat(userMods.ToWString("A"), userMods.ToWString("b"), userMods.ToWString("C"))

---          This returns a WString like userMods.ToWString("AbC").

function Concat(...)

  copyEditLine:SetText(common.GetEmptyWString())

  for k, v in arg do

    if v and common.IsWString(v) then

      copyEditLine:InsertTextAtCursorPos(v)

end

  end

  return copyEditLine:GetText()

end

We can made more functions, that are only two examples.

Also I have found the common.ExtractWStringFromValuedText function. I think, it is possible to copy text from the chat, for example.

Ссылка на комментарий
Поделиться на другие сайты

I saw the common.ExtractWStringFromValuedText function, from the 3.0 test API that I was given, as well. I was very excited about this function, since it should allow us to fetch ValuedTexts that were "off-limits" before. Like description texts and the map texts (different means than my current FullMap methods). This'll allow us to rewrite the color/size/shadowing/outline and so on of (possibly even add to) pre-existing ValuedTexts without having to recreate them entirely or instinctively knowing the fields required.

Ссылка на комментарий
Поделиться на другие сайты

EditLine functions were available monthes ago. UnitDetector should have used this function, i think.

But TextView ones are a precious gift.

Ссылка на комментарий
Поделиться на другие сайты

Гость
Ответить в этой теме...

×   Вставлено с форматированием.   Восстановить форматирование

  Разрешено использовать не более 75 эмодзи.

×   Ваша ссылка была автоматически встроена.   Отображать как обычную ссылку

×   Ваш предыдущий контент был восстановлен.   Очистить редактор

×   Вы не можете вставлять изображения напрямую. Загружайте или вставляйте изображения по ссылке.

×
×
  • Создать...

Важная информация

Пользуясь сайтом, вы принимаете Условия использования