示例#1
0
void pawsExchangeWindow::StartExchange( csString& player, bool withPlayer )
{
    csString text;
    if(!player.IsEmpty())
    {
        text.Format("Trading with %s",player.GetData());
    }

    int width;

    Clear();            
    Show();
            
    pawsTextBox* textBox = dynamic_cast <pawsTextBox*> (FindWidget("other_player"));
    if (textBox != NULL)
        textBox->SetText( text );

    if (withPlayer)
        width = 350;
    else
        width = 175;
    SetRelativeFrameSize(GetActualWidth(width), defaultFrame.Height());

    // Autoshow the inventory
    pawsWidget* widget = PawsManager::GetSingleton().FindWidget("SmallInventoryWindow");
    
    if (widget)
    {
        wasSmallInventoryOpen = widget->IsVisible();
        widget->Show();
    }
}        
void pawsWidgetTreeNode::SetWidget(pawsWidget* _widget)
{
    csRect widgetFrame;
    if(widget != NULL)
        pawsWidget::DeleteChild(widget);

    widget = _widget;
    widget->MoveTo(screenFrame.xmin, screenFrame.ymin);
    widgetFrame = widget->GetScreenFrame();
    SetRelativeFrameSize(widgetFrame.Width(), widgetFrame.Height());
    AddChild(widget);
}
void pawsSimpleTreeNode::Set(int mode, bool /*checked*/, const csString &imageName, const csString &label)
{
    csRect frame;
    int lastX;

    assert(tree != NULL);

    if(textBox != NULL)
    {
        widget->DeleteChild(textBox);
        textBox = NULL;
    }
    if(image != NULL)
    {
        widget->DeleteChild(image);
        image = NULL;
    }

    lastX = screenFrame.xmin - 1;
    if(mode & showCheckBox)
    {
        assert("checkbox nodes are not currently implemented"==0);
    }
    if(mode & showImage)
    {
        image = new pawsWidget();
        image->SetSize(20, 20);
        image->SetBackground(imageName);
        image->MoveTo(lastX+1, screenFrame.ymin);
        widget->AddChild(image);
        lastX += 20;
    }
    if(mode & showLabel)
    {
        textBox = new pawsTextBox;
        textBox->SetParent(widget);
        textBox->SetText(label);
        textBox->SetSizeByText(5,5);
        textBox->VertAdjust(pawsTextBox::vertCENTRE);
        textBox->MoveTo(lastX+1,0);

        widget->AddChild(textBox);
        lastX += textBox->GetScreenFrame().Width();
    }
    widget->SetRelativeFrame(0,0,lastX-screenFrame.xmin,20);
    widget->SetSize(lastX-screenFrame.xmin, 20);
    widget->MoveTo(0,0);
    SetRelativeFrameSize(lastX - screenFrame.xmin, 20);
}
void pawsSeqTreeNode::AddSeqWidget(pawsWidget* w, int width)
{
    csRect widgetFrame;

    widgets.PushBack(pawsSeqTreeNode_widget(w, width));

    AddChild(w);
    w->MoveTo(screenFrame.xmax+1, screenFrame.ymin);
    w->Show();

    int newWidth = width + defaultFrame.Width();
    int newHeight = csMax(w->GetDefaultFrame().Height(), defaultFrame.Height());

    SetRelativeFrameSize(newWidth, newHeight);
}
 pawsNumberInput()
 {
     SetRelativeFrameSize(110, 60);
     
     editBox = new pawsEditTextBox();
     AddChild(editBox);
     editBox->SetColour(graphics2D->FindRGB(255,255,255));
     editBox->SetRelativeFrame(20, 1, 70, 20);
     editBox->SetBackground("Scaling Field Background");
     
     scrollBar = new pawsScrollBar();
     scrollBar->SetHorizontal(true);        
     scrollBar->SetRelativeFrame(0, 33, 110, 20);
     scrollBar->SetTickValue(1);
     scrollBar->PostSetup();
     AddChild(scrollBar);
     
 }
示例#6
0
void pawsControlWindow::NextStyle()
{
    // We load it each time to make the user able to change the style without the need to
    // restart the client
    //Increase style
    style++;
    csString filename;
    filename = PawsManager::GetSingleton().GetLocalization()->FindLocalizedFile("control_styles.xml");
    if (!psengine->GetVFS()->Exists(filename.GetData()))
    {
        Error2( "Could not find XML: %s",filename.GetData());
        return;
    }

    csRef<iDocument> doc = ParseFile(psengine->GetObjectRegistry(),filename.GetData());
    if (!doc)
    {
        Error2("Error parsing file %s", filename.GetData());
        return;
    }

    csString topNodestr("style");
    topNodestr += style;

    csRef<iDocumentNode> root = doc->GetRoot();
    if (!root)
    {
        Error2("No XML root in %s", filename.GetData());
        return;
    }
    csRef<iDocumentNode> topNode = root->GetNode(topNodestr.GetData());

    //If "style"+style doesn't exist, jump to start
    if (!topNode)
    {
        if (style == 1) //No styles at all :(
            return;

        style=0;
        NextStyle();
        return;
    }

    csRef<iDocumentNodeIterator> iter = topNode->GetNodes();

    //Loop through the XML
    int bwidth=52, bheight=52, mwidth=16, mheight=16;
    float xscale=1.0f, yscale=1.0f;

    // get the current width and height of the buttons (should be the same for all)
    pawsButton* btn = (pawsButton*)FindWidget("QuitButton");
    int boldwidth = btn->ClipRect().Width();
    int boldheight = btn->ClipRect().Height();

    while ( iter->HasNext() )
    {
        csRef<iDocumentNode> node = iter->Next();
        if (!strcmp(node->GetValue(),"button"))
        {
            int x = GetActualWidth(node->GetAttributeValueAsInt("x"));
            int y = GetActualHeight(node->GetAttributeValueAsInt("y"));
            csString name = node->GetAttributeValue("name");

            pawsWidget* wdg = FindWidget(name.GetData());
            if (!wdg)
            {
                Error2("No such widget as %s!",name.GetData());
                continue;
            }
            wdg->SetSize(bwidth, bheight);
            wdg->SetRelativeFramePos(x, y);
        }
        else if (!strcmp(node->GetValue(),"buttons"))
        {
            bwidth = GetActualWidth(node->GetAttributeValueAsInt("width"));
            bheight = GetActualHeight(node->GetAttributeValueAsInt("height"));
            mwidth = GetActualWidth(node->GetAttributeValueAsInt("hide_width"));
            mheight = GetActualHeight(node->GetAttributeValueAsInt("hide_height"));

            // get the multiplier for the button and the widget size
            if (boldwidth != 0 && boldheight != 0)
            {
                xscale = float(boldwidth) / float(bwidth);
                yscale = float(boldheight) / float(bheight);
            }
        }
        else if (!strcmp(node->GetValue(), "bar"))
        {
            orgw = GetActualWidth(node->GetAttributeValueAsInt("width"));
            orgh = GetActualWidth(node->GetAttributeValueAsInt("height"));
            SetRelativeFrameSize(orgw, orgh);
            min_width = GetActualWidth(node->GetAttributeValueAsInt("min_w"));
            min_height = GetActualWidth(node->GetAttributeValueAsInt("min_h"));

            alwaysResize = node->GetAttributeValueAsBool("always_resize", true);
            SetResizeShow(alwaysResize);
        }
    }

    /* Resize the widget according to the proportions of the previous style.
     *
     * When the new styles dimensions exceeds its max it will be downsized to fit.
     * See: pawsWidget::Resize(int deltaX, int deltaY, int flags)
     */
    Resize( int(xscale*orgw-orgw), int(yscale*orgh-orgh), RESIZE_RIGHT | RESIZE_BOTTOM );

    // Set the minimize buttons size
    pawsButton* minUp = (pawsButton*)FindWidget("ShowButtonUp");
    minUp->SetSize(mwidth,mheight);

    pawsButton* minDown = (pawsButton*)FindWidget("ShowButtonDown");
    minDown->SetSize(mwidth,mheight);
}
示例#7
0
bool pawsControlWindow::OnButtonPressed( int mouseButton, int keyModifier, pawsWidget* reporter )
{
    if(reporter->GetID() == CONTROL_MINIDOWN || reporter->GetID() == CONTROL_MINIUP)
    {
        if (mouseButton == csmbRight)
        { //If the user clicked on the right mouse button, switch to another style
            if ( !hidden ) //don't allow to change styles while the toolbar is closed
                NextStyle();
            return true;
        }
        else if (mouseButton == csmbMiddle)
        {
            printf("Resetting toolbar to orginal size (%d,%d)\n",orgw,orgh);
            SetRelativeFrameSize(orgw,orgh);
            return true;
        }
    }

    switch ( reporter->GetID() )
    {
        case CONTROL_MINIUP:
        {
            if ( !hidden )
                Toggle();
            return true;
        }

        case CONTROL_MINIDOWN:
        {
            if ( hidden )
                Toggle();
            return true;
        }

        case CONTROL_QUIT:
        {
            HandleQuit();
            return true;
        }
        ////////////////////////////////////////////////////////////////////
        //Special cases that need more than the standard to open correctly
        ////////////////////////////////////////////////////////////////////

        ////////////////////////////////////////////////////////////////////
        // These two are from the confirm window buttons for quiting.
        ////////////////////////////////////////////////////////////////////
        case CONFIRM_YES:
        {
            psengine->QuitClient();
            return true;
        }
        case CONFIRM_NO:
        {
            PawsManager::GetSingleton().SetModalWidget( 0 );
            reporter->GetParent()->Hide();
            return true;
        }
        ////////////////////////////////////////////////////////////////////

        ////////////////////////////////////////////////////////////////////
        //Default handle for windows
        ////////////////////////////////////////////////////////////////////
        default:
        {
            pawsWidget* wdg = FindWidget(reporter->GetID());
            if (!wdg)
                return false;

            pawsControlledWindow* wnd = FindWindowFromButton(wdg->GetName());
            if (!wnd)
                return false;

            HandleWindow(wnd->GetName());
            return true;
        }
    }
    return false;
}