Esempio n. 1
0
void Addon::createGui(Window* window, unsigned id, unsigned short& y, bool /*readonly*/, unsigned /*status*/) const //-V669
{
    DrawPoint btPos(20, y), txtPos(52, y + 4);
    auto* button = window->GetCtrl<ctrlButton>(id + 1);
    if(!button)
        button = window->AddImageButton(id + 1, btPos, Extent(22, 22), TC_GREY, LOADER.GetImageN("io", 21), description_);

    button->SetVisible(true);
    button->SetPos(btPos);

    auto* text = window->GetCtrl<ctrlText>(id);
    if(!text)
        text = window->AddText(id, txtPos, name_, COLOR_YELLOW, FontStyle{}, NormalFont);

    text->SetVisible(true);
    text->SetPos(txtPos);
}
iwDistribution::iwDistribution(const GameWorldViewer& gwv, GameCommandFactory& gcFactory)
    : IngameWindow(CGI_DISTRIBUTION, IngameWindow::posLastOrCenter, Extent(290, 312), _("Distribution of goods"),
                   LOADER.GetImageN("resource", 41)),
      gwv(gwv), gcFactory(gcFactory), settings_changed(false)
{
    CreateGroups();

    // Tab Control
    ctrlTab* tab = AddTabCtrl(0, DrawPoint(10, 20), 270);
    DrawPoint txtPos(GetSize().x / 2, 60);
    DrawPoint progPos(PROGRESS_BORDER_DISTANCE - tab->GetPos().x, txtPos.y);
    const Extent progSize(GetSize().x - 2 * PROGRESS_BORDER_DISTANCE, 20);

    for(unsigned groupId = 0; groupId < groups.size(); groupId++)
    {
        const DistributionGroup& group = groups[groupId];
        ctrlGroup* tabGrp = tab->AddTab(group.img, group.name, groupId);
        txtPos.y = progPos.y = 60;
        unsigned curId = 0;
        for(const std::string& entry : group.entries)
        {
            unsigned txtId = group.entries.size() + curId;
            tabGrp->AddText(txtId, txtPos, entry, COLOR_YELLOW, FontStyle::CENTER | FontStyle::BOTTOM, SmallFont);
            tabGrp->AddProgress(curId++, progPos, progSize, TC_GREY, 139, 138, 10);
            txtPos.y = progPos.y += progSize.y * 2;
        }
    }

    // Gruppe auswählen
    tab->SetSelection(0);

    // Timer für die Übertragung der Daten via Netzwerk
    AddTimer(1, 2000);

    const Extent btSize(32, 32);
    // Hilfe
    AddImageButton(2, DrawPoint(15, GetSize().y - 15 - btSize.y), btSize, TC_GREY, LOADER.GetImageN("io", 225), _("Help"));
    // Standardbelegung
    AddImageButton(10, GetSize() - DrawPoint::all(15) - btSize, btSize, TC_GREY, LOADER.GetImageN("io", 191), _("Default"));

    UpdateSettings();
}
Esempio n. 3
0
void eos::TextEditor::OnPaint()
{
    ax::GC gc;
    ax::Rect rect(GetDrawingRect());
    
    gc.SetColor(_info.bg_color);
    gc.DrawRectangle(ax::Rect(0, 0, rect.size.x, rect.size.y));
    
    // Draw line number background.
    gc.SetColor(_info.line_number_bg_color);
    gc.DrawRectangle(ax::Rect(0, 0, 25, rect.size.y));
    
    ax::Point num_pos(4, 2);
    
    gc.SetColor(_info.line_number_color);
    
    // Draw line number.
    for(int i = 0; i < _n_line_shown; i++)
    {
        int num = i + _file_start_index;
        std::string num_str = std::to_string(num);
        
        if(num < 10)
        {
            num_str = "  " + num_str;
        }
        else if(num < 100)
        {
            num_str = " " + num_str;
        }

        gc.DrawString(_line_num_font, num_str, num_pos);
        
        num_pos += ax::Point(0, 15);
    }
    
    
    
    
    // Text initial position.
    //ax::Point line_pos(4, 0);
    ax::Point line_pos(25 + 4, 0);
    
    _next_pos_data.clear();
    
    const ax::StringVector& data = _logic.GetFileData();
    
    // Set text color.
    gc.SetColor(_info.text_color);
    
    // Draw text.
    for(int i = 0, k = _file_start_index;
        k < data.size() && i < _n_line_shown; i++, k++)
    {
        const std::string& text = data[k];
        
        std::vector<int> next_vec(text.size() + 1);
        
        // Draw string.
        if(_font)
        {
            int x = line_pos.x;
            
            next_vec[0] = x;
//
            //----------------------------------------
//            ax::StringVector words = ax::Utils::String::Split(text, " ");
//            
//            int index = 0;
//            
//            for(auto& w : words)
//            {
//                std::string clean_word = RemoveSpecialChar(w);
//                
//                ax::Color word_color = _info.text_color;
//                
//                if(_key_words_cpp.find(clean_word) != _key_words_cpp.end())
//                {
//                    word_color = ax::Color(0.6627451, 0.05098039, 0.5686275);
//                }
//
//                for (int i = 0; i < w.size(); i++)
//                {
//                    gc.SetColor(word_color);
//                    
//                    if(text[index] == ' ')
//                    {
//                        i--;
//                        _font.SetChar(' ');
//                    }
//                    else
//                    {
//                        _font.SetChar(w[i]);
//                        
//                        if(is_special(w[i]))
//                        {
//                            gc.SetColor(_info.text_color);
//                        }
//                        else if(std::isdigit(w[i]))
//                        {
//                            gc.SetColor(ax::Color(0.0, 0.0, 1.0));
//                        }
//                    }
//                    
//                    ax::Point d = _font.GetDelta();
//                    
//                    ax::Point txtPos(x + d.x,
//                                     line_pos.y - d.y + _font.GetFontSize());
//                    
//                    ax::Rect txtRect(txtPos, _font.GetSize());
//                    gc.DrawTexture(_font.GetTexture(), txtRect);
//                    
//                    x += _font.GetNextPosition();
//                    
//                    next_vec[index + 1] = x;
//                    
//                    index++;
//                    
//                }
//            }
//            
//            _font.SetChar(' ');
//            ax::Point d = _font.GetDelta();
//            
//            while(index < text.size())
//            {
//                ax::Point txtPos(x + d.x,
//                                 line_pos.y - d.y + _font.GetFontSize());
//                ax::Rect txtRect(txtPos, _font.GetSize());
//                gc.DrawTexture(_font.GetTexture(), txtRect);
//                x += _font.GetNextPosition();
//                next_vec[index + 1] = x;
//                index++;
//            }
            //------------------------
        
            
            for (int i = 0; i < text.size(); i++)
            {
                _font.SetChar(text[i]);
                ax::Point d = _font.GetDelta();
                
                ax::Point txtPos(x + d.x,
                                 line_pos.y - d.y + _font.GetFontSize());
                
                ax::Rect txtRect(txtPos, _font.GetSize());
                gc.DrawTexture(_font.GetTexture(), txtRect);
                
                x += _font.GetNextPosition();
                
                next_vec[i + 1] = x;
            }
        }
        
        _next_pos_data.push_back(next_vec);
        line_pos += ax::Point(0, 15);
    }
    
    // Line cursor.
    ax::Point cursor_index = FileCursorPosToNextPosIndex();
    
    if(cursor_index.x != -1 && cursor_index.y != -1)
    {
        ax::Print("Draw cursor");
        int x = _next_pos_data[cursor_index.y][cursor_index.x];
        int y = cursor_index.y * _line_height;
        
//        gc.SetColor(_info.cursor_color);
        gc.SetColor(ax::Color(1.0, 0.0, 0.0));
        gc.DrawLine(ax::Point(x, y), ax::Point(x, y + _line_height));
    }
}