Мануал: растягиваем диалоговое окно нпса и скрываем кнопку "закрыть"

Мишаня

Бессмертный
Партнер
Emu-Dev
Победитель в номинации 2023
Победитель в номинации 2022
Победитель в номинации 2021
Танкист
Любитель реакций
Неукротимое пламя
Стальной Визионер
Старожил I степени
Преподаватель
Клиент разработчик
Победитель в номинации 2019
Разработчик
За заслуги перед форумом
Сообщения
616
Розыгрыши
1
Решения
2
Репутация
721
Реакции
519
Баллы
1 613
Требуется компилятор interface.u, xdat editor ну и соответственно исходники interface.u
идем в исходники interface.u, открываем NPCDialogWnd.uc
вставляем следующий код:
Код:
//вверху
var ButtonHandle    exitButton;
var int hideexitbutton;
const oldwidth = 314;
const oldheigth = 408;

function OnLoad() //в эту функцию добавить код в соответствии с условием
{
    if(CREATE_ON_DEMAND==0)
    {
        exitButton = ButtonHandle( GetHandle( "NPCDialogWnd.exitbutton" ) );
    }
    else
    {
        exitButton = GetButtonHandle(  "NPCDialogWnd.exitbutton" );
    }
}

function OnEvent(int Event_ID, String param)//в эту функцию добавить код в соответствии с условием
{
    switch(Event_ID)
    {
    case EV_QuestIDWndLoadHtmlFromString:
        exitButton.HideWindow();
        break;
    }
}

function HandleLoadHtmlFromString(string param)//вставляем полностью вместо старой функции
{
    local string htmlString;
    local int i;
   
    ParseInt(param, "hideexitbutton", i);
    ParseInt(param, "whdwidth", width);
    ParseInt(param, "wndheight", heigth);
    hideexitbutton = i;    
    if(width > 0 && heigth > 0) {
        m_hNPCDialogWnd.setWindowSize(width, heigth);
    } else {
        m_hNPCDialogWnd.setWindowSize(oldwidth, oldheigth);
    }
    ParseString(param, "HTMLString", htmlString);
    m_hHtmlViewer.LoadHtmlFromString(htmlString);
}

function OnClickButton( string Name )//вставляем полностью вместо старой функции
{
    if( Name == "exitbutton" )                // 혈원 정보. 파티 초대
    {
        PressCloseButton();
        m_hNPCDialogWnd.HideWindow();
        exitButton.HideWindow();
    }
}

function HideNPCDialogWnd()//вставляем полностью вместо старой функции
{
    m_hNpcDialogWnd.HideWindow();
    exitButton.HideWindow();
    m_bReShowNPCDialogWnd = false;
}

function ShowNPCDialogWnd()//вставляем полностью вместо старой функции
{
    local PrivateShopWnd kPrivateShop;

    ExecuteEvent(EV_QuestHtmlWndHide);

    kPrivateShop = PrivateShopWnd(GetScript("PrivateShopWnd"));
    if (IsShowWindow("PrivateShopWnd"))
    {
        kPrivateShop.RequestQuit();
        HideWindow("PrivateShopWnd");
    }
    m_hNPCDialogWnd.ShowWindow();
    m_hNPCDialogWnd.SetFocus();
    if(hideexitbutton > 0) {//если параметр больше нуля - скрыть кнопку
        exitButton.HideWindow();
    } else {//иначе - показать
        exitButton.ShowWindow();
    }
    m_bReShowNPCDialogWnd = true;
}
сохраняем, компилируем interface.u
Открываем interface.xdat
скрипт под high five:
Код:
xdat.windows["NPCDialogWnd"].children.add(new Button())
xdat.windows["NPCDialogWnd"].children["null"].name = "exitbutton"
xdat.windows["NPCDialogWnd"].children["exitbutton"].parentName = "NPCDialogWnd"
xdat.windows["NPCDialogWnd"].children["exitbutton"].normalTex = "l2ui_ch3.FRAMECTRL.FrameCloseBtn"
xdat.windows["NPCDialogWnd"].children["exitbutton"].pushedTex = "l2ui_ch3.FRAMECTRL.FrameCloseOnBtn"
xdat.windows["NPCDialogWnd"].children["exitbutton"].buttonNameText = "undefined"
xdat.windows["NPCDialogWnd"].children["exitbutton"].size_absolute_width = 16
xdat.windows["NPCDialogWnd"].children["exitbutton"].size_absolute_height = 16
xdat.windows["NPCDialogWnd"].children["exitbutton"].anchored = true
xdat.windows["NPCDialogWnd"].children["exitbutton"].size = true
xdat.windows["NPCDialogWnd"].children["exitbutton"].alwaysOnTop = true
xdat.windows["NPCDialogWnd"].children["exitbutton"].relativePoint = Alignment.TOP_RIGHT
xdat.windows["NPCDialogWnd"].children["exitbutton"].anchorPoint = Alignment.TOP_RIGHT
xdat.windows["NPCDialogWnd"].children["exitbutton"].usePosition = true
xdat.windows["NPCDialogWnd"].children["exitbutton"].anchor_x = -6.0
xdat.windows["NPCDialogWnd"].children["exitbutton"].anchor_y = 7.0
xdat.windows["NPCDialogWnd"].exitbutton = false
сохраняем
теперь чтобы убрать кнопку "закрыть" у окна, или растянуть его, в штмл указываем параметры
Код:
<html noscrollbar hideexitbutton=1 whdwidth=400 wndheight=400> // к примеру так
 

Код:
//вверхы добавите тот строчек
const oldwidth1 = 294;
const oldheigth1 = 359;



 ParseString(param, "HTMLString", htmlString);
    if(width > 0 && heigth > 0) {
        m_hHtmlViewer.setWindowSize(width, heigth);
    } else {
        m_hHtmlViewer.setWindowSize(oldwidth1, oldheigth1);
    }
   
    m_hHtmlViewer.LoadHtmlFromString(htmlString);

Апдеит. Если вы ето не сделаете не будет смысл редактирование размер окна :) . (Сори за плохой рус)
 
I can't quite understand it. Is this method makes the said dialogues to have dynamic width and length, depending on the HTML that they show?

Example: an HTML with 275 width will show a normal-looking window575 width will be stretched to the sides.

Is there a way to do that? I've been looking around for so long and I couldn't find any indications of such a functionality/method.
 
Код:
//верх

const oldwidth = 314;
const oldheigth = 408;
const oldwidth1 = 294;
const oldheigth1 = 359;

function HandleLoadHtmlFromString(string param)//вставляем полностью вместо старой функции
{
    local string htmlString;
    local int i;
    local int width;
    local int heigth;
    local int width1;
    local int heigth1;
    
    
  
    ParseInt(param, "whdwidth", width);
    ParseInt(param, "wndheight", heigth);
    ParseInt(param, "whdwidth1", width1);
    ParseInt(param, "wndheight1", heigth1);
    if(width > 0 && heigth > 0) {
        m_hNPCDialogWnd.setWindowSize(width, heigth);
    } else {
        m_hNPCDialogWnd.setWindowSize(oldwidth, oldheigth);
    }
    ParseString(param, "HTMLString", htmlString);
    if(width1 > 0 && heigth1 > 0) {
        m_hHtmlViewer.setWindowSize(width1, heigth1);
    } else {
        m_hHtmlViewer.setWindowSize(oldwidth1, oldheigth1);
    }
    
    m_hHtmlViewer.LoadHtmlFromString(htmlString);
}

тег для .html фаила

Код:
<html noscrollbar whdwidth=400 wndheight=400 whdwidth1=390 wndheight1=390 >

где whdwidth и wndheight размер ОКНА ! и whdwidth1, wndheight1 размер ХТМЛ (HtmlViewer)
 
I can't quite understand it. Is this method makes the said dialogues to have dynamic width and length, depending on the HTML that they show?

Example: an HTML with 275 width will show a normal-looking window575 width will be stretched to the sides.

Is there a way to do that? I've been looking around for so long and I couldn't find any indications of such a functionality/method.
You can make custom dimensions for NPCDialogWnd with this script.Look at example this is NPCDialogWnd 1634585187492.png
 
чёто у вас как то громоздко всё выглядит
1634585920463.png

разве что под такой вариант нужно нормально настроить относительные размеры внутренних элементов окна
 
чёто у вас как то громоздко всё выглядит
Посмотреть вложение 39873

разве что под такой вариант нужно нормально настроить относительные размеры внутренних элементов окна
Нету опита, исползивал сурс который видел и переделал как смог. спасибо за share. Но в тот момент HTMLViewer width height не будет изменмен да ?
 
Нету опита, исползивал сурс который видел и переделал как смог. спасибо за share. Но в тот момент HTMLViewer width height не будет изменмен да ?
внутренний элемент можно заставить растягиваться на размер основного окна

тут есть вот такие понятия:
1634586740285.png

это значит, что элемент будет тянуться из левого верхнего угла до размера основного окна, но с правого края он будет короче на 54 пикселя
т.е. если размер главного окна 1000 пикселей, элемент внутри автоматически примет размер в 946 пикселей
 
Назад
Сверху Снизу