void pawsCharBirth::Randomize()
{
    pawsListBoxRow * row = months->Select(psengine->GetRandomGen().Get(months->GetRowCount()));
    if ( lastZodiacChoice != -1 )
    {
        createManager->RemoveChoice( lastZodiacChoice );            
    }
                                    
    createManager->AddChoice( row->GetID() );
    lastZodiacChoice = row->GetID();
    
    days->Select(psengine->GetRandomGen().Get(days->GetRowCount()));
   
    char widgetName[100];                
    sprintf( widgetName, "sibling%d", psengine->GetRandomGen().Get(sibCount) );
    pawsRadioButton* widget = (pawsRadioButton*) FindWidget(widgetName);
    pawsRadioButtonGroup* group = (pawsRadioButtonGroup*) FindWidget("Siblings");
    group->SetActive(widgetName);
    
    // Choose a random one to begin with.
    if (lastSiblingsChoice != -1)
        createManager->RemoveChoice( lastSiblingsChoice );      
    createManager->AddChoice( widget->GetID() );
    lastSiblingsChoice = widget->GetID();                           
    pawsMultiLineTextBox* siblingsDesc = (pawsMultiLineTextBox*) FindWidget("sibling_desc");
    siblingsDesc->SetText( createManager->GetDescription(widget->GetID()) );
    
    UpdateCP();
}
void pawsCharBirth::OnListAction( pawsListBox* widget, int status )
{
    if (status==LISTBOX_HIGHLIGHTED)
    {
        // Figure out which list box was checked and act accordingly
        pawsListBoxRow* row = widget->GetSelectedRow();            

        if (widget->GetID() == MONTH_COMBOBOX)
        {
            pawsWidget* imgBox = FindWidget("zodiac_img");
            pawsTextBox* textBox = (pawsTextBox*)FindWidget("zodiac");
            pawsMultiLineTextBox* descBox = (pawsMultiLineTextBox*)FindWidget("zodiac_description");

            if (!imgBox || !textBox || !descBox)
                return;

            Zodiac* zodiac = GetZodiac(widget->GetSelectedRowNum()+1);
            if (!zodiac)
            {
                Error2("No zodiac found for month number %d!",widget->GetSelectedRowNum()+1);
                return;
            }

            imgBox->SetBackground(zodiac->img);
            imgBox->SetBackgroundAlpha(0);
            textBox->SetText(zodiac->name);
            descBox->SetText(zodiac->desc);
            
            if ( lastZodiacChoice != -1 )
            {
                createManager->RemoveChoice( lastZodiacChoice );            
            }
                                    
            createManager->AddChoice( row->GetID() );
            lastZodiacChoice = row->GetID();
        
            UpdateCP();                        
        }
    }
    UpdateCP();
}
void pawsLifeEventWindow::PopulateFields()
{
    for (size_t x=0; x < createManager->lifeEventData.GetSize(); x++ )
    {
        if ( createManager->lifeEventData[x].common == 'Y' )
        {
            pawsListBoxRow* row = choiceSelection->CreateOption();
            pawsTextBox* text = (pawsTextBox*)row->GetColumn(0);
            text->SetText( createManager->lifeEventData[x].name );
            row->SetID( createManager->lifeEventData[x].id );
            text->FormatToolTip("%s %d\n", PawsManager::GetSingleton().Translate("CP Cost:").GetData(), createManager->lifeEventData[x].cpCost );
        }
    }
    UpdateCP();
}
Exemple #4
0
void pawsChildhoodWindow::Randomize()
{
    pawsListBox* birthBox = (pawsListBox*)FindWidget("bevent");
    pawsListBox* activityBox = (pawsListBox*)FindWidget("activity");
    pawsListBox* houseBox = (pawsListBox*)FindWidget("house");

    birthBox->Select(birthBox->GetRow(psengine->GetRandomGen().Get(birthBox->GetRowCount())));
    activityBox->Select(activityBox->GetRow(psengine->GetRandomGen().Get(activityBox->GetRowCount())));
    houseBox->Select(houseBox->GetRow(psengine->GetRandomGen().Get(houseBox->GetRowCount())));
    UpdateCP();

    // Update the choices made
    OnListAction(birthBox,LISTBOX_HIGHLIGHTED);
    OnListAction(activityBox,LISTBOX_HIGHLIGHTED);
    OnListAction(houseBox,LISTBOX_HIGHLIGHTED);
}
Exemple #5
0
void pawsChildhoodWindow::PopulateFields()
{    
    UpdateCP();
    for (size_t x=0; x < createManager->childhoodData.GetSize(); x++ )
    {
      
        switch ( createManager->childhoodData[x].choiceArea )
        {
            case BIRTH_EVENT:
            {
                pawsListBox* listbox = (pawsListBox*)FindWidget( "bevent" );
                pawsListBoxRow* row = listbox->NewRow();
                row->SetID( createManager->childhoodData[x].id );
                pawsTextBox* name = (pawsTextBox*)row->GetColumn(0);
                name->SetText( createManager->childhoodData[x].name  );   
                name->FormatToolTip("CP Cost: %d\n", createManager->childhoodData[x].cpCost );
                
                break;                  
            }
            
            case CHILD_ACTIVITY:
            {
                pawsListBox* listbox = (pawsListBox*)FindWidget( "activity" );
                pawsListBoxRow* row = listbox->NewRow();
                row->SetID( createManager->childhoodData[x].id );
                pawsTextBox* name = (pawsTextBox*)row->GetColumn(0);
                name->SetText( createManager->childhoodData[x].name  );          
                name->FormatToolTip("CP Cost: %d\n", createManager->childhoodData[x].cpCost );     
                break;
            }
            
            case CHILD_HOUSE:
            {
                
                pawsListBox* houseBox = (pawsListBox*)FindWidget("house");
                pawsListBoxRow* row = houseBox->NewRow();
                row->SetID( createManager->childhoodData[x].id );
                pawsTextBox* name = (pawsTextBox*)row->GetColumn(0);
                name->SetText( createManager->childhoodData[x].name  );   
                name->FormatToolTip("CP Cost: %d\n", createManager->childhoodData[x].cpCost );
                break;
            }          
        }   
    }      
}
Exemple #6
0
void pawsChildhoodWindow::OnListAction( pawsListBox* widget, int status )
{
    if (status==LISTBOX_HIGHLIGHTED)
    {
        // Figure out which list box was checked and act accordingly
        pawsListBoxRow* row = widget->GetSelectedRow();            
        
        switch ( widget->GetID() )
        {
            case EVENT_LISTBOX:
            {
                 
                createManager->RemoveChoice( lastEventChoice );
                createManager->AddChoice( row->GetID() );
                lastEventChoice = row->GetID();
                
                eventDesc->SetText( createManager->GetDescription(row->GetID()) );
                break;        
            }        
            case ACTIVITY_LISTBOX:
            {
     
                createManager->RemoveChoice( lastActivityChoice );
                createManager->AddChoice( row->GetID() );
                lastActivityChoice = row->GetID();        
                
                activityDesc->SetText( createManager->GetDescription(row->GetID()) );
                break;        
            }        

            case HOUSE_LISTBOX:
            {   
     
                createManager->RemoveChoice( lastHouseChoice );
                createManager->AddChoice( row->GetID() );
                lastHouseChoice = row->GetID();                 
                
                houseDesc->SetText( createManager->GetDescription(row->GetID()) );
                break;
            }
        }   
        UpdateCP();
    };
}
/// Adds a 'moved' life event to a characters generation, and resolves dependent
/// life events
void pawsLifeEventWindow::AddLifeEventAndDependencies (void)
{
    pawsListBoxRow* moved = choiceSelection->GetMoved();    
    int id = moved->GetID();
    createManager->AddLifeEvent( id );

    if ( id != -1 )
    {
        LifeEventChoice* event = createManager->FindLifeEvent( id );
        if (event != NULL)
        {
            // Remove the ones this choices removes
            for (size_t ridx = 0; ridx < event->removes.GetSize(); ridx++ )
            {
                choiceSelection->RemoveFromAvailable( event->removes[ridx] );
            }                                    
    
            // Add in the new option this choices opens up                
            for (size_t aidx = 0; aidx < event->adds.GetSize(); aidx++ )
            {
                LifeEventChoice* addevent = createManager->FindLifeEvent( event->adds[aidx] );
                if (addevent != NULL)
                {
                    pawsListBoxRow* row = choiceSelection->CreateOption();         
                    pawsTextBox* text = (pawsTextBox*)row->GetColumn(0);
                    text->SetText( addevent->name );
                    row->SetID( addevent->id );                                    
                }
                else
                    Error2("Failed to find life event %i", event->adds[aidx]);
            }                                    
        }
        else
            Error2("Failed to find life event %i", id);
    }

    UpdateCP();
}
Exemple #8
0
void pawsChildhoodWindow::Show()
{
    UpdateCP();
    pawsWidget::Show();    
}
bool pawsLifeEventWindow::OnButtonPressed(int /*mouseButton*/, int /*keyModifier*/, pawsWidget* widget)
{
    if ( strcmp(widget->GetName(),"randomize") == 0 )
    {
        Randomize();
        return true;
    }

    switch ( widget->GetID() )
    {
        case SELECTOR_ADD_BUTTON:
        {
            AddLifeEventAndDependencies();
            return true;
        }
        
        case SELECTOR_REMOVE_BUTTON:
        {
            pawsListBoxRow* moved = choiceSelection->GetMoved();    
            int id = moved->GetID();
            createManager->RemoveLifeEvent( id );
            LifeEventChoice* event = createManager->FindLifeEvent( id );
            
            if (event != NULL)
            {
                // remove this choice and any of the ones it adds
                for (size_t ridx = 0; ridx < event->adds.GetSize(); ridx++ )
                {
                    choiceSelection->RemoveFromAvailable( event->adds[ridx] );
                    choiceSelection->RemoveFromSelected( event->adds[ridx] );
                    createManager->RemoveLifeEvent( event->adds[ridx] );
                }                                    
                            
                if ( id != -1 )
                {
                    for (size_t ridx = 0; ridx < event->removes.GetSize(); ridx++ )
                    {
                        LifeEventChoice* addevent = createManager->FindLifeEvent( event->removes[ridx] );
                        if (addevent != NULL)
                        {
                            pawsListBoxRow* row = choiceSelection->CreateOption();         
                            pawsTextBox* text = (pawsTextBox*)row->GetColumn(0);
                            text->SetText( addevent->name );
                            row->SetID( addevent->id );
                        }
                        else
                            Error2("Failed to find life event %i", event->removes[ridx]);
                    }
                }
            }
            else
                Error2("Failed to find life event %i", id);
            UpdateCP();
            return true;                        
        }
               
        case BACK_BUTTON:
        {
            Hide();
            PawsManager::GetSingleton().FindWidget( "Childhood" )->Show();
            return true;
        }
        
        case NEXT_BUTTON:
        {
            if (createManager->GetNumberOfLifeChoices() == 0)
            {
                psSystemMessage error(0,MSG_ERROR,PawsManager::GetSingleton().Translate("Please choose life event(s)"));
                error.FireEvent();
                return true;
            }
            Hide();
            pawsSummaryWindow* window = (pawsSummaryWindow*)PawsManager::GetSingleton().FindWidget( "Summary" );
            window->Update();
            window->Show();
            return true;
        }
      
    }
    
    return false;
}
void pawsLifeEventWindow::Show()
{
    pawsWidget::Show();
    UpdateCP();  
}
void pawsCharBirth::Show()
{
    pawsWidget::Show();
    UpdateCP();  
}