Example #1
0
void
mps_redraw(void)
{
    Rect* mps = &scr.mappoint_stats;

    draw_small_bezel (mps->x, mps->y, mps->w, mps->h, yellow(0));
    mps_refresh();
}
void print_stats ()
{
    // this show update the financy window or mps
    if (total_time % NUMOF_DAYS_IN_MONTH == (NUMOF_DAYS_IN_MONTH - 1))
    {
        update_pbars_monthly();
        mps_refresh();
        getEconomyGraph()->updateData();
    }

    if (total_time % (NUMOF_DAYS_IN_MONTH/5) == NUMOF_DAYS_IN_MONTH / 5 - 1)
    {   mps_refresh();}

    //check for new tech
    update_avail_modules (1);

}
Example #3
0
int
mps_set(int x, int y, int style)
{
    int same_square = 0;
    mps_style = style;
    switch(style) {
    case MPS_MAP:
    case MPS_ENV:
        if (mps_x == x && mps_y == y) {
            same_square = 1;
        }
        mps_x = x;
        mps_y = y;
        break;
    default:
        mps_x = 0;
        mps_y = 0;
    }

    mps_update();
    mps_refresh();
    return same_square;
}
Example #4
0
void Dialog::applyMarketButtonClicked( Button* ){
    CheckButton* cb;
    Market * market = static_cast <Market *> (world(pointX, pointY)->construction);
    cb = getCheckButton( *myDialogComponent, "BuyJobs" );
    if( cb->state == CheckButton::STATE_CHECKED ){
        market->commodityRuleCount[Construction::STUFF_JOBS].take = true;
    } else {
        market->commodityRuleCount[Construction::STUFF_JOBS].take = false;
    }
    cb = getCheckButton( *myDialogComponent, "SellJobs" );
    if( cb->state == CheckButton::STATE_CHECKED ){
        market->commodityRuleCount[Construction::STUFF_JOBS].give = true;
    } else {
        market->commodityRuleCount[Construction::STUFF_JOBS].give = false;
    }
    cb = getCheckButton( *myDialogComponent, "BuyFood" );
    if( cb->state == CheckButton::STATE_CHECKED ){
        market->commodityRuleCount[Construction::STUFF_FOOD].take = true;
    } else {
        market->commodityRuleCount[Construction::STUFF_FOOD].take = false;
    }
    cb = getCheckButton( *myDialogComponent, "SellFood" );
    if( cb->state == CheckButton::STATE_CHECKED ){
        market->commodityRuleCount[Construction::STUFF_FOOD].give = true;
    } else {
        market->commodityRuleCount[Construction::STUFF_FOOD].give = false;
    }
    cb = getCheckButton( *myDialogComponent, "BuyCoal" );
    if( cb->state == CheckButton::STATE_CHECKED ){
        market->commodityRuleCount[Construction::STUFF_COAL].take = true;
    } else {
        market->commodityRuleCount[Construction::STUFF_COAL].take = false;
    }
    cb = getCheckButton( *myDialogComponent, "SellCoal" );
    if( cb->state == CheckButton::STATE_CHECKED ){
        market->commodityRuleCount[Construction::STUFF_COAL].give = true;
    } else {
        market->commodityRuleCount[Construction::STUFF_COAL].give = false;
    }
    cb = getCheckButton( *myDialogComponent, "BuyOre" );
    if( cb->state == CheckButton::STATE_CHECKED ){
        market->commodityRuleCount[Construction::STUFF_ORE].take = true;
    } else {
        market->commodityRuleCount[Construction::STUFF_ORE].take = false;
    }
    cb = getCheckButton( *myDialogComponent, "SellOre" );
    if( cb->state == CheckButton::STATE_CHECKED ){
        market->commodityRuleCount[Construction::STUFF_ORE].give = true;
    } else {
        market->commodityRuleCount[Construction::STUFF_ORE].give = false;
    }
    cb = getCheckButton( *myDialogComponent, "BuyGoods" );
    if( cb->state == CheckButton::STATE_CHECKED ){
        market->commodityRuleCount[Construction::STUFF_GOODS].take = true;
    } else {
        market->commodityRuleCount[Construction::STUFF_GOODS].take = false;
    }
    cb = getCheckButton( *myDialogComponent, "SellGoods" );
    if( cb->state == CheckButton::STATE_CHECKED ){
        market->commodityRuleCount[Construction::STUFF_GOODS].give = true;
    } else {
        market->commodityRuleCount[Construction::STUFF_GOODS].give = false;
    }
    cb = getCheckButton( *myDialogComponent, "BuySteel" );
    if( cb->state == CheckButton::STATE_CHECKED ){
        market->commodityRuleCount[Construction::STUFF_STEEL].take = true;
    } else {
        market->commodityRuleCount[Construction::STUFF_STEEL].take = false;
    }
    cb = getCheckButton( *myDialogComponent, "SellSteel" );
    if( cb->state == CheckButton::STATE_CHECKED ){
        market->commodityRuleCount[Construction::STUFF_STEEL].give = true;
    } else {
        market->commodityRuleCount[Construction::STUFF_STEEL].give = false;
    }
    cb = getCheckButton( *myDialogComponent, "BuyWaste" );
    if( cb->state == CheckButton::STATE_CHECKED ){
        market->commodityRuleCount[Construction::STUFF_WASTE].take = true;
    } else {
        market->commodityRuleCount[Construction::STUFF_WASTE].take = false;
    }
    cb = getCheckButton( *myDialogComponent, "SellWaste" );
    if( cb->state == CheckButton::STATE_CHECKED ){
        market->commodityRuleCount[Construction::STUFF_WASTE].give = true;
    } else {
        market->commodityRuleCount[Construction::STUFF_WASTE].give = false;
    }
    mps_refresh();
    desktop->remove( myDialogComponent );
    blockingDialogIsOpen = false;
    unRegisterDialog();
}
Example #5
0
void
mps_update(void)
{
    int i;

    for (i = 0; i < MAPPOINT_STATS_LINES; i++) {
        strcpy(mps_info[i],"");
    }

    switch (mps_style) {
    case MPS_MAP:
    {
        switch(MP_GROUP(mps_x, mps_y)) {
        case (GROUP_BLACKSMITH):
            mps_blacksmith (mps_x, mps_y);
            break;
        case (GROUP_COALMINE):
            mps_coalmine (mps_x, mps_y);
            break;
        case GROUP_COAL_POWER:
            mps_coal_power (mps_x, mps_y);
            break;
        case (GROUP_COMMUNE):
            mps_commune (mps_x, mps_y);
            break;
        case (GROUP_CRICKET):
            mps_cricket (mps_x, mps_y);
            break;
        case (GROUP_FIRESTATION):
            mps_firestation (mps_x, mps_y);
            break;
        case (GROUP_HEALTH):
            mps_health_centre (mps_x, mps_y);
            break;
        case (GROUP_INDUSTRY_H):
            mps_heavy_industry (mps_x, mps_y);
            break;
        case (GROUP_INDUSTRY_L):
            mps_light_industry (mps_x, mps_y);
            break;
        case (GROUP_MILL):
            mps_mill (mps_x, mps_y);
            break;
        case (GROUP_MONUMENT):
            mps_monument (mps_x, mps_y);
            break;
        case (GROUP_OREMINE):
            mps_oremine (mps_x, mps_y);
            break;
        case GROUP_ORGANIC_FARM:
            mps_organic_farm(mps_x, mps_y);
            break;
        case (GROUP_PORT):
            mps_port (mps_x, mps_y);
            break;
        case (GROUP_POTTERY):
            mps_pottery (mps_x, mps_y);
            break;
        case GROUP_POWER_LINE:
            mps_power_line (mps_x, mps_y);
            break;
        case (GROUP_RAIL):
            mps_rail (mps_x, mps_y);
            break;
        case (GROUP_RECYCLE):
            mps_recycle (mps_x, mps_y);
            break;
        case GROUP_RESIDENCE_LL:
        case GROUP_RESIDENCE_ML:
        case GROUP_RESIDENCE_HL:
        case GROUP_RESIDENCE_LH:
        case GROUP_RESIDENCE_MH:
        case GROUP_RESIDENCE_HH:
            mps_residence(mps_x, mps_y);
            break;
        case (GROUP_ROAD):
            mps_road (mps_x, mps_y);
            break;
        case (GROUP_ROCKET):
            mps_rocket (mps_x, mps_y);
            break;
        case (GROUP_SCHOOL):
            mps_school (mps_x, mps_y);
            break;
        case GROUP_SOLAR_POWER:
            mps_solar_power (mps_x, mps_y);
            break;
        case (GROUP_SUBSTATION):
            mps_substation (mps_x, mps_y);
            break;
        case (GROUP_TIP):
            mps_tip (mps_x, mps_y);
            break;
        case (GROUP_TRACK):
            mps_track(mps_x, mps_y);
            break;
        case (GROUP_MARKET):
            mps_market (mps_x, mps_y);
            break;
        case (GROUP_UNIVERSITY):
            mps_university (mps_x, mps_y);
            break;
        case (GROUP_WATER):
            mps_water (mps_x, mps_y);
            break;
        case (GROUP_WINDMILL):
            mps_windmill (mps_x, mps_y);
            break;
        default:
            printf("MPS unimplemented for that module\n");
            mps_style = MPS_NONE;
        }
    }
    break;
    case MPS_ENV:
        mps_right (mps_x, mps_y);
        break;
    case MPS_GLOBAL:
    {
        switch (mps_global_style) {
        case MPS_GLOBAL_FINANCE:
            mps_global_finance();
            break;
        case MPS_GLOBAL_OTHER_COSTS:
            mps_global_other_costs();
            break;
        case MPS_GLOBAL_HOUSING:
            mps_global_housing();
            break;
        default:
            printf("MPS unimplemented for global display\n");
            break;
        }
    }
    break;
    }

    mps_refresh();
}
Example #6
0
MainState
Game::run()
{
    SDL_Event event;
    running = true;
    Uint32 fpsTicks = SDL_GetTicks();
    Uint32 lastticks = fpsTicks;
    Desktop* desktop = dynamic_cast<Desktop*> (gui.get());
    if(!desktop)
    {   throw std::runtime_error("Toplevel component is not a Desktop");}
    gui->resize(getConfig()->videoX, getConfig()->videoY);
    int frame = 0;
    while(running) {
        getGameView()->scroll();
        while(SDL_PollEvent(&event)) {
            switch(event.type) {
                case SDL_VIDEORESIZE:
                    initVideo(event.resize.w, event.resize.h);
                    gui->resize(event.resize.w, event.resize.h);
                    getConfig()->videoX = event.resize.w;
                    getConfig()->videoY = event.resize.h;
                    break;
                case SDL_KEYUP: {
                     Event gui_event(event);
                     if( gui_event.keysym.sym == SDLK_ESCAPE ){
                         getButtonPanel()->selectQueryTool();
                         break;
                     }
                     if( gui_event.keysym.sym == SDLK_b ){
                         getButtonPanel()->toggleBulldozeTool();
                         break;
                     }
/*                  //FIXME hack for monitoring constructionCount
                    if( gui_event.keysym.sym == SDLK_c ){
                         std::cout << "ConstructionCount.size() = " << constructionCount.size() << std::endl;
                         int i, j;
                         for (i = 0, j = 0; i < constructionCount.size(); i++) {constructionCount[i]?j++:j;}
                         std::cout << "for a total of " << j << " active constructions" << std::endl;
                         break;
                     }
*/
                     if( gui_event.keysym.sym == SDLK_p ){

                            static int i = 0;
                            while(i < constructionCount.size() && !constructionCount[i]) {i++;}
                            if (i < constructionCount.size())
                            {
                                main_screen_originx = constructionCount[i]->x;
                                main_screen_originy = constructionCount[i]->y;
                                getGameView()->readOrigin(true);
                                mps_set( main_screen_originx, main_screen_originy, MPS_MAP);
                                mps_update();
                                mps_refresh();
                                i++;
                            }
                            else
                            {
                                i = 0;
                            }
                         break;
                     }
                     if( gui_event.keysym.sym == SDLK_F1 ){
                         helpWindow->showTopic("help");
                         break;
                     }
                     if( gui_event.keysym.sym == SDLK_F12 ){
                         quickSave();
                         break;
                     }
                     if( gui_event.keysym.sym == SDLK_F9 ){
                         quickLoad();
                         break;
                     }
#ifdef DEBUG
                     if( gui_event.keysym.sym == SDLK_F5 ){
                         testAllHelpFiles();
                         break;
                     }
#endif
                     int need_break=true;
                     switch(gui_event.keysym.sym) {
                       case SDLK_BACKQUOTE: getMiniMap()->mapViewChangeDisplayMode(MiniMap::NORMAL); break;
                       case SDLK_1: getMiniMap()->mapViewChangeDisplayMode(MiniMap::STARVE); break;
                       case SDLK_2: getMiniMap()->mapViewChangeDisplayMode(MiniMap::UB40); break;
                       case SDLK_3: getMiniMap()->mapViewChangeDisplayMode(MiniMap::POWER); break;
                       case SDLK_4: getMiniMap()->mapViewChangeDisplayMode(MiniMap::FIRE); break;
                       case SDLK_5: getMiniMap()->mapViewChangeDisplayMode(MiniMap::CRICKET); break;
                       case SDLK_6: getMiniMap()->mapViewChangeDisplayMode(MiniMap::HEALTH); break;
                       case SDLK_7: getMiniMap()->mapViewChangeDisplayMode(MiniMap::TRAFFIC); break;
                       case SDLK_8: getMiniMap()->mapViewChangeDisplayMode(MiniMap::POLLUTION); break;
                       case SDLK_9: getMiniMap()->mapViewChangeDisplayMode(MiniMap::COAL); break;
                       case SDLK_0: getMiniMap()->mapViewChangeDisplayMode(MiniMap::COMMODITIES); break;
                       default:  need_break=false;
                     }
                     if (need_break) break;

                     gui->event(gui_event);
                     break;
                }
                case SDL_MOUSEMOTION:
                case SDL_MOUSEBUTTONUP:
                case SDL_MOUSEBUTTONDOWN:
                case SDL_KEYDOWN: {
                    Event gui_event(event);
                    gui->event(gui_event);
                    break;
                }
                case SDL_ACTIVEEVENT:
                    if( event.active.gain == 1 ){
                        gui->resize( gui->getWidth(), gui->getHeight() );
                    }
                    break;
                case SDL_VIDEOEXPOSE:
                    gui->resize( gui->getWidth(), gui->getHeight() );
                    break;
                case SDL_QUIT:
                    saveCityNG( "9_currentGameNG.scn" );
                    running = false;
                    quitState = QUIT;
                    break;
                default:
                    break;
            }
        }

        // create update Event
        Uint32 ticks = SDL_GetTicks();
        float elapsedTime = ((float) (ticks - lastticks)) / 1000.0;
        gui->event(Event(elapsedTime));
        lastticks = ticks;

        helpWindow->update();
        if(desktop->needsRedraw())
        {
            desktop->draw(*painter);
            flipScreenBuffer();
        }

        frame++;
        // Slow down cpu consumption in pause mode
        if(ticks - fpsTicks > 1000 && lincitySpeed)
        {
#ifdef DEBUG_FPS
            printf("FPS: %d.\n", (frame*1000) / (ticks - fpsTicks));
#endif
            getEconomyGraph()->newFPS( frame );
            frame = 0;
            fpsTicks = ticks;
        }
        else if(!lincitySpeed)
        {   frame = 0;}
        /* SDL_Delay is done in execute_timestep */
        execute_timestep ();
    }
    return quitState;
}