예제 #1
0
static int hero2sub2_event_notify(activity *act, enum im_evnet_category_t e_category, int event, void* value)
{
    if (e_category == EC_RKE) {
        enum update_request_action_t pact = (enum update_request_action_t) event;
        if (pact == UR_RANGE) {
#if 0
            /* If RKE reports correctly, stop demo animation. */
            stopDemoAnimation();
#endif
            setElectricity();
            setFuel();
            setMile();
            update_fully_charge_time();
        }
        else if (pact == UR_CODING) {
            /* Language changed */
            setup_labels();
        }
    } else if (e_category == EC_CHANGE) {
        if ((enum im_change_evnet_t) event == EVENT_CONNECTION_STATUS) {
            update_fully_charge_time();
        }
    }
    return 0;
}
예제 #2
0
static void setup_labels()
{
    LiteBox *box;

    pthread_mutex_lock(&ui_mutex);
    //num label
    lite_set_box_visible(LITE_BOX(rangeNumLabel), false);
    //setup_label_by_tag(rangeNumLabel, "LS_KMNUM");
    pthread_mutex_unlock(&ui_mutex);

    setMile();

    pthread_mutex_lock(&ui_mutex);
    lite_set_box_visible(LITE_BOX(rangeNumLabel), true);

    //km label
    enum mileage_unit mUnit = getInfoManager()->get_mileage_unit();
    if (mUnit == MILEAGE_UNIT_MILE) {
        setup_label_by_tag(kmLabel, "LS_MI");
    }
    else {
        /* MILEAGE_UNIT_KM */
        setup_label_by_tag(kmLabel, "LS_KM");
    }
    //lite_set_label_alignment(kmLabel, LITE_LABEL_RIGHT);

    /* total range label */
    setup_label_by_tag_color(titleLabel, "LS_TOTAL_RANGE", &Colors.blue);

    /* fully charged label */
    lite_set_box_visible(LITE_BOX(fullyChargeLabel), false);
    setup_label_by_tag_color(fullyChargeLabel, "LS_FULLCHARGE_TIME", &Colors.steelBlue);

    pthread_mutex_unlock(&ui_mutex);

    /*
    // electricity label
    box = LITE_BOX(elecNumLabel);
    box->rect.x = 60; box->rect.y = 142; box->rect.w = 200; box->rect.h = 44;
    lite_set_label_color(elecNumLabel, &TITLE_COLOR);
    lite_set_label_font(elecNumLabel, FONT_BMWTACD, LITE_FONT_PLAIN, SUBPAGE_TITLE_FONT_SIZE, 0);
    lite_reinit_box_and_children(box);
    //lite_draw_box(box->parent, NULL, DFB_TRUE);

    // fuel label
    box = LITE_BOX(fuelNumLabel);
    box->rect.x = 60; box->rect.y = 190; box->rect.w = 200; box->rect.h = 44;
    lite_set_label_color(fuelNumLabel, &TITLE_COLOR);
    lite_set_label_font(fuelNumLabel, FONT_BMWTACD, LITE_FONT_PLAIN, SUBPAGE_TITLE_FONT_SIZE, 0);
    lite_reinit_box_and_children(box);
    //lite_draw_box(box->parent, NULL, DFB_TRUE);
    */

    setElectricity();
    setFuel();
    update_fully_charge_time();
}
예제 #3
0
/**
 * Update stats of craft.
 * @param s
 */
void Craft::addCraftStats(const RuleCraftStats& s)
{
	setDamage(_damage + s.damageMax); //you need "fix" new damage capability first before use.
	_stats += s;

	int overflowFuel = _fuel - _stats.fuelMax;
	if (overflowFuel > 0 && !_rules->getRefuelItem().empty())
	{
		_base->getStorageItems()->addItem(_rules->getRefuelItem(), overflowFuel / _rules->getRefuelRate());
	}
	setFuel(_fuel);
}
예제 #4
0
static void demoThreadHandler() {
    static int elecCount = 0;
    static int fuelCount = 0;
    while(1) {
        if( isAnimationStart == 1 ) {
            elecCount += 200 / MAX_ELECTRIC_DISPLAY_LEVEL;
            fuelCount += 255 / MAX_FUEL_DISPLAY_LEVEL;
            if (elecCount > 200) elecCount = 0;
            if (fuelCount > 254) fuelCount = 0;
            setElectricity(elecCount);
            setFuel(fuelCount);
        }
        usleep(1000000);
    }
}
예제 #5
0
/**
 * Refuels the craft every 30 minutes
 * while it's docked in the base.
 */
void Craft::refuel()
{
	setFuel(_fuel + _rules->getRefuelRate());
	if (_fuel >= _rules->getMaxFuel())
	{
		_status = "STR_READY";
		for (std::vector<CraftWeapon*>::iterator i = _weapons.begin(); i != _weapons.end(); ++i)
		{
			if (*i && (*i)->isRearming())
			{
				_status = "STR_REARMING";
				break;
			}
		}
	}
}
예제 #6
0
static int onCreate(int mode, activity *act) {
    if( onCreateSanityCheck(act) != MKD_OK ) {
        return MKD_ERR;
    }
    //Start to construct the window
    loadWindow(act);

    //Set event notify
    getInfoManager()->register_event_notify(act, EC_RKE, UR_RANGE | UR_CODING, hero2sub2_event_notify);
    getInfoManager()->register_event_notify(act, EC_CHANGE, EVENT_CONNECTION_STATUS, hero2sub2_event_notify);

    setup_labels();
    setElectricity();
    setFuel();
    setMile();
    update_fully_charge_time();
    return MKD_OK;
}
예제 #7
0
/**
 * Consumes the craft's fuel every 10 minutes
 * while it's on the air.
 */
void Craft::consumeFuel()
{
	setFuel(_fuel - getFuelConsumption());
}