Ejemplo n.º 1
0
int main()
{
    int Anz = 7;
//    int Ende = 1;

    char Menu[50] = "TerminVerwaltung V 0.2";
    char *Menupunkte[] = {"Neuen Termin anlegen", "Termin bearbeiten", "Termin loeschen", "Termin suchen", "Termine sortieren", "Termine auflisten", "Programm beenden"};


   //TDate Date;
   //TTime Time;
   //char Input[20];

   do
   {
      clearScreen();
       int Wahl = getMenu( Menu , Menupunkte , Anz);

        printf("ToDo:");

        switch(Wahl)
        {
            case 1: createAppointment(); break;
            case 2: editAppointment();   break;
            case 3: deleteAppointment(); break;
            case 4: searchAppointment(); break;
            case 5: sortCalendar();      break;
            case 6: listCalendar();      break;
//            case 7: printf("Das Programm wird beendet");
//                   Ende = 0;             break;
            default: printf("Falsche Wahl\n\n");
        }
   } while (askAgain("Moechten Sie noch einmal (j//n) ? "));
   return 0;
}
Ejemplo n.º 2
0
void ListView::keyPressEvent(QKeyEvent *e)
{
    if (e->key()){
        int key = e->key();
        if (e->state() & ShiftButton)
            key |= SHIFT;
        if (e->state() & ControlButton)
            key |= CTRL;
        if (e->state() & AltButton)
            key |= ALT;
        QListViewItem *item = currentItem();
        if (item){
            ProcessMenuParam *mp = getMenu(item);
            if (mp){
                mp->key	 = key;
                Event eMenu(EventProcessMenu, mp);
                if (eMenu.process())
                    return;
            }
        }
    }
    if (e->key() == Key_F10){
        showPopup(currentItem(), QPoint());
        return;
    }
    QListView::keyPressEvent(e);
}
Ejemplo n.º 3
0
void MenuBar::activateMenuAtPosition(const glm::vec2 &position)
{
    glm::vec2 itemPosition;
    int newItemIndex;
    auto item = getItemAtPosition(position, &newItemIndex, &itemPosition);
    if (!item)
        return;

    if (activated && activeItemIndex == newItemIndex)
        return;

    killAllPopUps();
    activated = true;
    activeItemIndex = newItemIndex;
    auto &subMenu = item->getMenu();
    if (subMenu)
    {
        subMenu->setPosition(getAbsolutePosition() + glm::vec2(itemPosition.x, getHeight()));
        subMenu->popUp(sharedFromThis());
    }
    else
    {
        item->activated();
    }
}
Ejemplo n.º 4
0
Game::Game()
{
    device = irr::createDevice(irr::video::EDT_OPENGL, {640,480}, 16, false, false, false, &event_receiver);

    assert(device);

    device->setWindowCaption(L"Eternal Sonata");
    
    driver = device->getVideoDriver();
    scene_manager = device->getSceneManager();
    environment = device->getGUIEnvironment();
    menu.setDevice(device);
    menu.setDevice(device);
    this->mapSelector = 0;
    this->game_set = false;
    character.setEventReceiver(&event_receiver);

    loadMeshes();
    loadMap();
    loadPlayer();


    getMenu().showMainMenu();

    getPlayer().debugCharacter();
}
Ejemplo n.º 5
0
int main() {
	int n;
	int choice;
	char sections[3][100] = {"Convert the decimal number into binary form",
	                         "Convert the decimal number into hexadecimal form", "Exit"
	                        };
	stack_type *s;
	s = iniStack(s);

	do {
		choice = getMenu(sections, 3);
		switch (choice) {
		case 1:
			printf("Type in a decimal number n: ");
			scanf("%d", &n);
			detoBinary(n, s);
			break;
		case 2:
			printf("Type in a decimal number n: ");
			scanf("%d", &n);
			detoHex(n, s);
			break;
		case 3:
			break;
		default: printf("Invalid choice. It must be from 1 to %d\n", 3);
			break;
		}
	} while (choice != 3);
	return 0;
}
Ejemplo n.º 6
0
void MenuButton::onButton() {
	if (_source) {
		auto menu = getMenu();
		CC_SAFE_RETAIN(menu);

		if (auto cb = _source->getCallback()) {
			cb(this, _source);
		}
		if (auto nextMenu = _source->getNextMenu()) {
			auto scene = Scene::getRunningScene();
			auto size = scene->getContentSize();

			auto posLeft = convertToWorldSpace(cocos2d::Vec2(0, _contentSize.height));
			auto posRight = convertToWorldSpace(cocos2d::Vec2(_contentSize.width, _contentSize.height));

			float pointLeft = posLeft.x;
			float pointRight = size.width - posRight.x;

			if (pointRight >= pointLeft) {
				construct<FloatingMenu>(nextMenu, posRight, FloatingMenu::Binding::OriginRight,
						dynamic_cast<FloatingMenu *>(_menu));
			} else {
				construct<FloatingMenu>(nextMenu, posLeft, FloatingMenu::Binding::OriginLeft,
						dynamic_cast<FloatingMenu *>(_menu));
			}
		}
		if (menu) {
			menu->onMenuButtonPressed(this);
			menu->release();
		}
	}
}
Ejemplo n.º 7
0
void Menu::drawMenuHilite(int curMenu) {
	AgiMenu *m = getMenu(curMenu);

	debugC(6, kDebugLevelMenu, "[%s]", m->text);

	_vm->printText(m->text, 0, m->col, 0, 40, MENU_BG, MENU_FG);
	_vm->flushLines(0, 0);
}
Ejemplo n.º 8
0
void Menu::drawMenuOptionHilite(int hMenu, int vMenu) {
	AgiMenu *m = getMenu(hMenu);
	AgiMenuOption *d = getMenuOption(hMenu, vMenu);

	// Disabled menu items are "greyed out" with a checkerboard effect,
	// rather than having a different color. -- dsymonds
	_vm->printText(d->text, 0, m->wincol + 1, vMenu + 2, m->width + 2,
			MENU_BG, MENU_FG, !d->enabled);
}
Ejemplo n.º 9
0
bool System::handleMouseButton(EventArgs::MouseButtons btn, EventArgs::ButtonState state)
{
    if(m_exclusiveInputWindow)
        return m_exclusiveInputWindow->onMouseButton(btn, state);

    m_activateTooltip = false;
    hideTooltip(m_containsMouse);

    if (!m_rootWindow) return false;

    WindowBase* target = m_captureWindow ? m_captureWindow : m_containsMouse;

    if(!target)
        target = m_rootWindow.get();

    if(m_focusWindow != target)
    {
        auto focusWnd = target->isTabStop() ? target : NULL;
        queryInputFocus(focusWnd);
    }

    // Drag'n'Drop support
    if(btn == EventArgs::Left && !m_dragfired)
    {
        if(target != m_rootWindow.get() && target != m_captureWindow)
        {
            if(target->isDraggable() && state == EventArgs::Down)
            {
                m_dragfired = false;
                m_dragOffset = m_cursor.getPosition();
                m_dragWindow = target;
                m_dragging = true;
            }
        }

        if(state == EventArgs::Up && m_dragging)
        {
            m_dragging = false;
        }
    }

    target->rise();

    if(target != m_menuWindow.get())
        getMenu()->reset();

    while(target)
    {
        if(target->onMouseButton(btn, state))
            return true;
        target = const_cast<WindowBase*>(target->getParent());
    }

    return false;
}
Ejemplo n.º 10
0
int main()
{
  char choice;
  char name[80];
  int number;
  int found;
  SymbolTable book;
  int i;
  /* initialize phone book */
  book = createSymbolTable(&makePhoneBook, &comparePhone);

  do{
    choice = getMenu();
    switch(choice){

    case '1':
      printf("Enter the name: ");
      scanf("%[^\n]", name);
      myfflush();
      printf("Enter the number: ");
      scanf("%d", &number);
      myfflush();
      addEntry(&number, &name, &book);
      printf("%d\n", book.total);
      break;

    case '2':
      printf("Enter the number you want to find: ");
      scanf("%d", &number);
      myfflush();
      found = getEntryValue(&number, &book);
      if(found == -1) printf("Not found\n");
      else{
	displayTitle();
	displayEntry(book.entries[found]);
      }      
      break;

    case '3':
      displayTitle();
      for(i = 0; i < book.current; i++){
	displayEntry(book.entries[i]);
      }
      break;

    case '4':
      dropSymbolTable(&book);
      break;
      
    default: printf("Invalid choice\n");
    }
  }while(choice != EXIT);
}
Ejemplo n.º 11
0
AgiMenuOption *Menu::getMenuOption(int i, int j) {
	AgiMenu *m = getMenu(i);
	MenuOptionList::iterator iter;

	for (iter = m->down.begin(); iter != m->down.end(); ++iter) {
		AgiMenuOption* d = *iter;
		if (d->index == j)
			return d;
	}

	return NULL;
}
Ejemplo n.º 12
0
/*****************************************************************
 * 函数名称:execGame
 * 描述说明:运行连连看游戏
 * 输入参数:p_gameUi:游戏体指针,blockNum:当前关数
 * 输出参数:1:重新开始当前关2:返回3:闯关成功4:超时5:死局
*****************************************************************/
int execGame(gameUi_t *p_gameUi, int blockNum)
{
	int ret = 0;
	struct LcdDot touchXY;

	gameExeFlag = 1;
	restTime = 75;
	noConnectTime = 0;
	initGame(p_gameUi, blockNum);
	showGame(p_gameUi);
	
	while(1){
		while(GetTouch(&touchXY) == 0);

		if(restTime <= 0){
			gameExeFlag = 0;
			return 4;
		}

		if(noConnectTime > 3){
			if(haveConnect(&p_gameUi->m_mat) == 0){
				gameExeFlag = 0;
				return 5;
			}else{
				noConnectTime = 0;
			}
		}

		ret = doGame(&p_gameUi->m_gameMng, &p_gameUi->m_mat, &touchXY);
		if(ret != 0){//按在矩阵内
			if(ret == 2){//点击第二次
				if(seccess(&p_gameUi->m_gameMng)){
					gameExeFlag = 0;
					return 3;
				}else{
					//gameDelay(1000);
					//showGame(p_gameUi);	
				}
			}
		}else{//按在矩阵外
			//showGame(p_gameUi);
			ret = getMenu(&p_gameUi->m_ui, &touchXY);

			if(ret > 0){
				gameExeFlag = 0;
				return ret;
			}
		}
	}

	return 0;
}
Ejemplo n.º 13
0
void PopupMenu::addAction(QAction* action)
{
   if(MusEGlobal::config.scrollableSubMenus)
   {
      return QMenu::addAction(action);
   }
   static_cast<QMenu*>(getMenu())->addAction(action);
   int w = _cur_menu->actionGeometry(action).width();
   if(w > _cur_item_width)
      _cur_item_width = w;
   int c = _cur_menu->columnCount();
   if(c > _cur_col_count)
      _cur_col_count = c;
}
Ejemplo n.º 14
0
QAction* PopupMenu::addAction(const QIcon& icon, const QString& text)
{
   if(MusEGlobal::config.scrollableSubMenus)
   {
      return QMenu::addAction(icon, text);
   }
   QAction* act = static_cast<QMenu*>(getMenu())->addAction(icon, text);
   int w = _cur_menu->actionGeometry(act).width();
   if(w > _cur_item_width)
      _cur_item_width = w;
   int c = _cur_menu->columnCount();
   if(c > _cur_col_count)
      _cur_col_count = c;
   return act;
}
Ejemplo n.º 15
0
QAction* PopupMenu::addAction(const QIcon& icon, const QString& text, const QObject* receiver, const char* member, const QKeySequence& shortcut)
{
   if(MusEGlobal::config.scrollableSubMenus)
   {
      return QMenu::addAction(icon, text, receiver, member, shortcut);
   }
   QAction* act = static_cast<QMenu*>(getMenu())->addAction(icon, text, receiver, member, shortcut);
   int w = _cur_menu->actionGeometry(act).width();
   if(w > _cur_item_width)
      _cur_item_width = w;
   int c = _cur_menu->columnCount();
   if(c > _cur_col_count)
      _cur_col_count = c;
   return act;
}
Ejemplo n.º 16
0
void MenuBar::handleMouseButtonDown(MouseButtonEvent &event)
{
    BaseType::handleMouseButtonDown(event);

    // Deactivate the menu if it was active
    if (activated)
    {
        killAllPopUps();
        auto item = getItemAtPosition(event.getPosition(), nullptr, nullptr);
        if (item && !item->getMenu())
            item->activated();
        return;
    }

    activateMenuAtPosition(event.getPosition());
}
Ejemplo n.º 17
0
// draw box and pulldowns.
void Menu::drawMenuOption(int hMenu) {
	// find which vertical menu it is
	AgiMenu *m = getMenu(hMenu);

	_gfx->drawBox(m->wincol * CHAR_COLS, 1 * CHAR_LINES, (m->wincol + m->width + 2) * CHAR_COLS,
			(1 + m->height + 2) * CHAR_LINES, MENU_BG, MENU_LINE, 0);

	MenuOptionList::iterator iter;

	for (iter = m->down.begin(); iter != m->down.end(); ++iter) {
		AgiMenuOption* d = *iter;

		_vm->printText(d->text, 0, m->wincol + 1, d->index + 2, m->width + 2,
				MENU_FG, MENU_BG, !d->enabled);
	}
}
Ejemplo n.º 18
0
void ListView::showPopup(QListViewItem *item, QPoint p)
{
    if (item == NULL) return;
    ProcessMenuParam *mp = getMenu(item);
    if (mp == NULL)
        return;
    if (p.isNull()){
        QRect rc = itemRect(item);
        p = QPoint(rc.x() + rc.width() / 2, rc.y() + rc.height() / 2);
        p = viewport()->mapToGlobal(p);
    }
    mp->key	 = 0;
    Event eMenu(EventProcessMenu, mp);
    QPopupMenu *menu = (QPopupMenu*)eMenu.process();
    if (menu)
        menu->popup(p);
}
Ejemplo n.º 19
0
void SinglePopupEditor::testPopup()
{

	if(m_pTestPopup)
		delete m_pTestPopup;
	m_pTestPopup = getMenu();
	if(!m_pTestPopup)
		return;
	connect(m_pTestPopup, SIGNAL(testModeItemClicked(KviKvsPopupMenuItem *)), this, SLOT(testModeMenuItemClicked(KviKvsPopupMenuItem *)));
	QPoint pnt = m_pMenuButton->mapToGlobal(QPoint(0, m_pMenuButton->height()));
	KviKvsVariantList * parms = new KviKvsVariantList();
	parms->append(new KviKvsVariant(QString("test1")));
	parms->append(new KviKvsVariant(QString("test2")));
	parms->append(new KviKvsVariant(QString("test3")));
	parms->append(new KviKvsVariant(QString("test4")));
	m_pTestPopup->doPopup(pnt, g_pActiveWindow, parms, true);
}
Ejemplo n.º 20
0
void Menu::addMenuItem(const MenuItemProperties& properties) {
    MenuWrapper* menuObj = getMenu(properties.menuName);
    if (menuObj) {
        QShortcut* shortcut = NULL;
        if (!properties.shortcutKeySequence.isEmpty()) {
            shortcut = new QShortcut(properties.shortcutKeySequence, this);
            shortcut->setContext(Qt::WidgetWithChildrenShortcut);
        }

        // check for positioning requests
        int requestedPosition = properties.position;
        if (requestedPosition == UNSPECIFIED_POSITION && !properties.beforeItem.isEmpty()) {
            requestedPosition = findPositionOfMenuItem(menuObj, properties.beforeItem);
            // double check that the requested location wasn't a separator label
            requestedPosition = positionBeforeSeparatorIfNeeded(menuObj, requestedPosition);
        }
        if (requestedPosition == UNSPECIFIED_POSITION && !properties.afterItem.isEmpty()) {
            int afterPosition = findPositionOfMenuItem(menuObj, properties.afterItem);
            if (afterPosition != UNSPECIFIED_POSITION) {
                requestedPosition = afterPosition + 1;
            }
        }

        QAction* menuItemAction = NULL;
        if (properties.isSeparator) {
            addDisabledActionAndSeparator(menuObj, properties.menuItemName, requestedPosition, properties.grouping);
        } else if (properties.isCheckable) {
            menuItemAction = addCheckableActionToQMenuAndActionHash(menuObj, properties.menuItemName,
                                                                    properties.shortcutKeySequence, properties.isChecked,
                                                                    MenuScriptingInterface::getInstance(), SLOT(menuItemTriggered()),
                                                                    requestedPosition, properties.grouping);
        } else {
            menuItemAction = addActionToQMenuAndActionHash(menuObj, properties.menuItemName, properties.shortcutKeySequence,
                                                           MenuScriptingInterface::getInstance(), SLOT(menuItemTriggered()),
                                                           QAction::NoRole, requestedPosition, properties.grouping);
        }
        if (shortcut && menuItemAction) {
            connect(shortcut, SIGNAL(activated()), menuItemAction, SLOT(trigger()));
        }
        QMenuBar::repaint();
    }
}
Ejemplo n.º 21
0
int main(int argc, char** argv) {
    char str[] = {0x1b, 0x5b, 0x48, 0x1b, 0x5b, 0x4a, '\0'};
    printf("%s", str);
    int opt = 0;
    do{
        opt = getMenu();
        switch(opt){
            case 1:
		iniciarJuego();
		break;
            case 2:
		aboutMe();
		break;
        }
        printf("Pulse una tecla para continuar\n");
	getchar();
	printf("%s", str);
    }while( opt != 3);
    return 0;
}
Ejemplo n.º 22
0
	bool MainMenuWindow::handleChooseModule(MenuItem* it, ContentModule* module)
	{
		MenuBase* modulesMenu = getMenu("MainMenu/Modules/Menu");

		ItemEntry* itOld = NULL;
		for (size_t i=0; i<modulesMenu->getItemCount(); i++)
		{
			ItemEntry* curr = modulesMenu->getItemFromIndex(i);
			if (curr->getText().compare(mActiveModule->getName()+" *") == 0)
			{
				itOld = curr;
				break;
			}
		}
		itOld->setText(mActiveModule->getName());

		mActiveModule = module;
		it->setText(module->getName()+" *");

		return true;
	}
Ejemplo n.º 23
0
void MainWindow::setDockWidget(int id, QDockWidget* dock, QAF::DockWidgetPos pos/* = QAF::DWP_AUTO*/)
{
	if (dock && !mDockWidgets.contains(id))
	{
		//寻找具有相同挂载位置的dock
		dock->setProperty("dockPos", (int)pos);
		QDockWidget* lastDock = nullptr;
		foreach(QDockWidget* widget, mDockWidgets){
			if (widget && widget->property("dockPos").toInt() == pos){
				lastDock = widget;
			}
		}

		this->addDockWidget((Qt::DockWidgetArea)pos, dock);
		QAction* toggle = dock->toggleViewAction();
		getMenu(QAF::MI_VIEW)->addAction(toggle);
		mDockWidgets.insert(id, dock);

		if (lastDock){
			this->tabifyDockWidget(lastDock, dock);
		}
	}
Ejemplo n.º 24
0
int setMenu(int id)
{
	int i=0;
	menu_un Menu_temp;
	int menu_start_addr=0;
	for(i=0;i<MENU_DATA_LENGTH;i++)
	{
		Menu_temp.data[i]=Menu.data[i];
	}
	menu_start_addr=MENU_DATA_START_ADDR+(id*MENU_DATA_LENGTH);
	for(i=0;i<MENU_DATA_LENGTH;i++)
	{
		i2c_eeprom_write_byte(menu_start_addr+i,Menu_temp.data[i]);
		delay(50);
	}
	getMenu(id);
	for(i=0;i<MENU_DATA_LENGTH;i++)
	{
		if(Menu_temp.data[i]!=Menu.data[i])
			return 0;
	}
	return 1;
}
QMenu *TikzCommandInserter::getMenu()
{
	return getMenu(m_tikzSections);
}
QMenu *TikzCommandInserter::getMenu(const TikzCommandList &commandList)
{
	QMenu *menu = new QMenu(commandList.title, m_parentWidget);
	const int numOfCommands = commandList.commands.size();
	QAction *action = new QAction("test", menu);
	int whichSection = 0;

	// get left margin of the menu (to be added to the minimum width of the menu)
	menu->addAction(action);
	QFont actionFont = action->font();
	actionFont.setPointSize(actionFont.pointSize() - 1);
	QFontMetrics actionFontMetrics(actionFont);
	int menuLeftMargin = menu->width() - actionFontMetrics.boundingRect(action->text()).width();
	menu->removeAction(action);
	int menuMinimumWidth = 0;

	for (int i = 0; i < numOfCommands; ++i)
	{
		const QString name = commandList.commands.at(i).name;
		if (name.isEmpty()) // add separator or submenu
		{
			if (commandList.commands.at(i).type == 0)
			{
				action = new QAction(menu);
				action->setSeparator(true);
				menu->addAction(action);
			}
			else // type == -1, so add submenu; this assumes that the i-th command with type == -1 corresponds with the i-th submenu (see getCommands())
			{
				menu->addMenu(getMenu(commandList.children.at(whichSection)));
				++whichSection;
			}
		}
		else // add command
		{
			action = new QAction(name, menu);
			action->setData(commandList.commands.at(i).number); // link to the corresponding item in m_tikzCommandsList
			action->setStatusTip(commandList.commands.at(i).description);
			menuMinimumWidth = qMax(menuMinimumWidth, actionFontMetrics.boundingRect(commandList.commands.at(i).description).width());
			connect(action, SIGNAL(triggered()), this, SLOT(insertTag()));
			connect(action, SIGNAL(hovered()), this, SLOT(updateDescriptionMenuItem()));
			menu->addAction(action);
		}
	}

	// if the menu does not only contain submenus, then we add a menu item
	// at the bottom of the menu which shows the description of the currently
	// highlighted menu item
	if (whichSection < menu->actions().size())
	{
		action = new QAction(this);
		action->setSeparator(true);
		menu->addAction(action);

		action = new QAction(this);
		QFont actionFont = action->font();
		actionFont.setPointSize(actionFont.pointSize() - 1);
		action->setFont(actionFont);
		connect(action, SIGNAL(triggered()), this, SLOT(insertTag()));
		menu->addAction(action);

		// make sure that the menu width does not change when the content
		// of the above menu item changes
		menu->setMinimumWidth(menuMinimumWidth + menuLeftMargin);
	}

	return menu;
}
Ejemplo n.º 27
0
void *LiveJournalClient::processEvent(Event *e)
{
    TCPClient::processEvent(e);
    if (e->type() == EventOpenMessage) {
        Message **msg = (Message**)(e->param());
        if ((*msg)->type() != MessageUpdated)
            return NULL;
        if (dataName(&data.owner) != (*msg)->client())
            return NULL;
        Event eDel(EventMessageDeleted, msg);
        eDel.process();
        string url = "http://";
        url += getServer();
        if (getPort() != 80) {
            url += ":";
            url += number(getPort());
        }
        url += "/";
        Event eGo(EventGoURL, (void*)url.c_str());
        eGo.process();
        if (getState() == Connected)
            m_timer->start(getInterval() * 60 * 1000, true);
        return e->param();
    }
    if (e->type() == EventCommandExec) {
        CommandDef *cmd = (CommandDef*)(e->param());
        if (cmd->id == CmdDeleteJournalMessage) {
            Message *msg = (Message*)(cmd->param);
            Contact *contact = getContacts()->contact(msg->contact());
            if (contact == NULL)
                return NULL;
            LiveJournalUserData *data;
            ClientDataIterator it(contact->clientData, this);
            while ((data = (LiveJournalUserData*)(++it)) != NULL) {
                if (dataName(data) == msg->client()) {
                    Buffer cfg;
                    cfg << "[Title]\n" << msg->save().c_str();
                    cfg.setWritePos(0);
                    cfg.getSection();
                    JournalMessage *m = new JournalMessage(&cfg);
                    m->setContact(msg->contact());
                    m->setOldID(msg->id());
                    m->setText("");
                    if (!send(m, data))
                        delete m;
                    return e->param();
                }
            }
            return NULL;
        }
        unsigned menu_id = cmd->menu_id - MenuWeb;
        if (menu_id > LiveJournalPlugin::MenuCount)
            return NULL;
        unsigned item_id = cmd->id - CmdMenuWeb;
        if ((item_id == 0) || (item_id >= 0x100))
            return NULL;
        const char *url = getMenuUrl(menu_id * 0x100 + item_id);
        if ((url == NULL) || (*url == 0))
            return NULL;
        Event eUrl(EventGoURL, (void*)url);
        eUrl.process();
        return e->param();
    }
    if (e->type() == EventCheckState) {
        CommandDef *cmd = (CommandDef*)(e->param());
        if (cmd->id == CmdMenuWeb) {
            unsigned menu_id = cmd->menu_id - MenuWeb;
            if (menu_id > LiveJournalPlugin::MenuCount)
                return NULL;
            unsigned nItems = 0;
            unsigned list_id = menu_id * 0x100 + 1;
            for (;;) {
                const char *text = getMenu(list_id);
                if ((text == NULL) || (*text == 0))
                    break;
                nItems++;
                list_id++;
            }
            if (nItems == 0)
                return NULL;
            CommandDef *cmds = new CommandDef[nItems + 1];
            memset(cmds, 0, sizeof(CommandDef) * (nItems + 1));
            list_id = menu_id * 0x100 + 1;
            for (unsigned i = 0;; i++) {
                const char *text = getMenu(list_id);
                if ((text == NULL) || (*text == 0))
                    break;
                cmds[i].text = "_";
                if (strcmp(text, "-")) {
                    cmds[i].id = CmdMenuWeb + i + 1;
                    cmds[i].text = "_";
                    QString s = i18n(text);
                    cmds[i].text_wrk = strdup(s.utf8());
                    const char *url = getMenuUrl(list_id);
                    if (url && (*url == '@')) {
                        unsigned nSub = atol(url + 1);
                        while (nSub > LiveJournalPlugin::MenuCount) {
                            unsigned long menu_id = MenuWeb + (++LiveJournalPlugin::MenuCount);
                            Event eMenu(EventMenuCreate, (void*)menu_id);
                            eMenu.process();
                            Command cmd;
                            cmd->id       = CmdMenuWeb;
                            cmd->text     = "_";
                            cmd->menu_id  = menu_id;
                            cmd->menu_grp = 0x1000;
                            cmd->flags    = COMMAND_CHECK_STATE;
                            Event e(EventCommandCreate, cmd);
                            e.process();
                        }
                        cmds[i].popup_id = MenuWeb + nSub;
                    }
                } else {
                    cmds[i].id = 0;
                }
                list_id++;
            }
            cmd->param = cmds;
            cmd->flags |= COMMAND_RECURSIVE;
            return e->param();
        }
    }
    return NULL;
}
Ejemplo n.º 28
0
int main()
{
	sdcard_Init();
	initVGA();
	initAnonProfile();
	brickmap = malloc(sizeof(BrickMap));
	currentLevel->paddle = malloc(sizeof(Paddle));
	currentLevel->buff=malloc(sizeof(Buff));
	int i,j;
	for(i=0;i<maxBalls;i++)
		currentLevel->ball[i] = malloc(sizeof(Ball));

	for(i=0;i<maxRows;i++)
		for(j=0;j<bricksPerRow;j++)
			currentLevel->bricks[i][j]=malloc(sizeof(Brick));


	level=1;


	//pre load the root menu
	getMenu(&currentMenu,rootMenu, 1);

	//allocate memory for level farm


	//set the game to playing
	prevState=currentState=Playing;


	//look up the level from level farm and load it into currentLevel
	levelLookUp(brickmap,level);
	initLevel(*brickmap);
	drawStart(currentLevel);   //this is optional here
	swapBuffers();
	drawStart(currentLevel);

	runCountDown();              //count down from three
	initInterrupt();            //start the game (we dont need to right off the bat (probably shouldnt)

	int counter=0;   //so were not doing direct IO reads on EVERY iteration (we could timer this buttttt no)
	while(1)
	{
		//input to state machine
		counter++;
		if(counter>22000)
		{
			counter=0;
			if(getMenuPB())
			{
				while(getMenuPB() != 0);
				if(currentState == Playing)
					changeState(MenuShow);
			}
		}
		//flicker changes
		if(prevState != currentState)
		{
			if(currentState == Playing)
			{
				clearScreen();
				drawStart(currentLevel);   //this is optional here
				swapBuffers();
				drawStart(currentLevel);
				runCountDown();
				initInterrupt();
			}else
			{
				stopInterrupt();
				getMenu(&currentMenu,rootMenu, 1);
				clearScreen();
				drawStart(currentLevel);   //this is optional here
				swapBuffers();
				drawStart(currentLevel);
				drawMenu(currentMenu);
			}
			prevState = currentState;
		}
		//state machine
		if(currentState == MenuShow)
		{
			menuLoop();
		}else //while were playing we will have to check for other things (all balls gone etc.)
		{
			if(currentLevel->brickCount<=0)
			{
				printf("starting new level \n");
				stopInterrupt();
				level++;
				levelLookUp(brickmap,level);
				initLevel(*brickmap);
				prevState= currentState - 1;
				currentState = Playing;
				printf("finished starting new level \n");
			}
		}
	}
	return 0;
}
Ejemplo n.º 29
0
void CALLBACK dispatchEvents(SIMCONNECT_RECV*  pData, DWORD  cbData, void *  pContext)
{
	HRESULT hr;

	switch (pData->dwID)
	{
	case SIMCONNECT_RECV_ID_EVENT:
	{
		SIMCONNECT_RECV_EVENT *evt = (SIMCONNECT_RECV_EVENT*)pData;

		switch (evt->uEventID)
		{
		case STARTUP:
			stats.lastDeleted = 0;
			stats.nrOfDeletions = 0;
			stats.nrOfRequests = 0;
			// Now the sim is running, request information on the user aircraft
			hr = SimConnect_RequestDataOnSimObjectType(hSimConnect, R1, AIPARKDATA, conf.radius, SIMCONNECT_SIMOBJECT_TYPE_AIRCRAFT);
			++stats.nrOfRequests;
			break;


		case R2:
			fsecCnt++;

			if (fsecCnt >= (conf.requestEveryXSec/4))
			{
				fsecCnt = 0;
				if (SUCCEEDED(SimConnect_RequestDataOnSimObjectType(hSimConnect, R1, AIPARKDATA, conf.radius, SIMCONNECT_SIMOBJECT_TYPE_AIRCRAFT)))
				{
					++stats.nrOfRequests;
				}
			}
			break;

		case MENU:
			getMenu(menu, sizeof(menu));
			SimConnect_Text(hSimConnect, SIMCONNECT_TEXT_TYPE_MENU, 0, SELECTION, sizeof(menu), (void*)menu);
			break;

		case SELECTION:
			res = (SIMCONNECT_TEXT_RESULT)(evt->dwData);
			switch (res) {
			case SIMCONNECT_TEXT_RESULT_MENU_SELECT_1:
				if (conf.requestEveryXSec < 3600)
				{
					conf.requestEveryXSec += 30;
				}
				getMenu(menu, sizeof(menu));
				SimConnect_Text(hSimConnect, SIMCONNECT_TEXT_TYPE_MENU, 0, SELECTION, sizeof(menu), (void*)menu);
				break;

			case SIMCONNECT_TEXT_RESULT_MENU_SELECT_2:
				if (conf.requestEveryXSec > 45)
				{
					conf.requestEveryXSec -= 30;
				}
				getMenu(menu, sizeof(menu));
				SimConnect_Text(hSimConnect, SIMCONNECT_TEXT_TYPE_MENU, 0, SELECTION, sizeof(menu), (void*)menu);
				break;

			case SIMCONNECT_TEXT_RESULT_MENU_SELECT_3:
				if (conf.radius < 190000)
				{
					conf.radius += 5000;
				}
				getMenu(menu, sizeof(menu));
				SimConnect_Text(hSimConnect, SIMCONNECT_TEXT_TYPE_MENU, 0, SELECTION, sizeof(menu), (void*)menu);
				break;

			case SIMCONNECT_TEXT_RESULT_MENU_SELECT_4:
				if (conf.radius > 5000)
				{
					conf.radius -= 5000;
				}
				getMenu(menu, sizeof(menu));
				SimConnect_Text(hSimConnect, SIMCONNECT_TEXT_TYPE_MENU, 0, SELECTION, sizeof(menu), (void*)menu);
				break;

			case SIMCONNECT_TEXT_RESULT_MENU_SELECT_5:
				if (conf.maxetd > 5400)
				{
					conf.maxetd -= 3600;
				}
				getMenu(menu, sizeof(menu));
				SimConnect_Text(hSimConnect, SIMCONNECT_TEXT_TYPE_MENU, 0, SELECTION, sizeof(menu), (void*)menu);
				break;


			case SIMCONNECT_TEXT_RESULT_MENU_SELECT_6:
				if (conf.maxetd < 7*86400) // must be smaller than a week
				{
					conf.maxetd += 3600;
				}
				getMenu(menu, sizeof(menu));
				SimConnect_Text(hSimConnect, SIMCONNECT_TEXT_TYPE_MENU, 0, SELECTION, sizeof(menu), (void*)menu);
				break;

			case SIMCONNECT_TEXT_RESULT_MENU_SELECT_8:
				SimConnect_Text(hSimConnect, SIMCONNECT_TEXT_TYPE_MENU, 0, SELECTION, sizeof(empty), (void*)empty);
				break;
			default: //default cannot be close as displayed is also an event
				break;
			}
			saveConfig(conf);
			break;
		default:
			break;
		}
		break;
	}


	case SIMCONNECT_RECV_ID_SIMOBJECT_DATA_BYTYPE:
	{
		SIMCONNECT_RECV_SIMOBJECT_DATA_BYTYPE *pObjData = (SIMCONNECT_RECV_SIMOBJECT_DATA_BYTYPE*)pData;

		switch (pObjData->dwRequestID)
		{
		case R1:
		{
			DWORD ObjectID = pObjData->dwObjectID;
			DWORD entry = pObjData->dwentrynumber;
			DWORD outof = pObjData->dwoutof;
			DWORD length = pObjData->dwDefineCount;
			AIData *pS = (AIData*)&pObjData->dwData;
			if (ObjectID != SIMCONNECT_OBJECT_ID_USER)
			{
				if (strcmp(pS->state, "sleep") == 0 && pS->ETD > conf.maxetd)
				{
					if (FS10DeleteAIAircraft != NULL)
					{
						FS10DeleteAIAircraft(ObjectID, 1);
						++stats.nrOfDeletions;
						deletedSome = true;
					}
				}
			}

			if (entry == outof)
			{
				if (deletedSome)
				{
					stats.lastDeleted = GetTickCount64();
				}
				deletedSome = false;
			}


		}

		default:
			break;
		}
		break;
	}

	case SIMCONNECT_RECV_ID_EXCEPTION:
	{
		SIMCONNECT_RECV_EXCEPTION *except = (SIMCONNECT_RECV_EXCEPTION*)pData;
		printf("\n\n***** EXCEPTION=%d  SendID=%d  Index=%d  cbData=%d\n", except->dwException, except->dwSendID, except->dwIndex, cbData);
		break;
	}

	case SIMCONNECT_RECV_ID_QUIT:
	{
		quit = 1;
		break;
	}

	default:
		printf("\nReceived:%d", pData->dwID);
		break;
	}
}
Ejemplo n.º 30
0
void MenuButton::layoutSubviews() {
	auto height = 48.0f;

	auto menu = getMenu();
	if (!menu) {
		return;
	}
	auto menuMetrics = menu->getMetrics();

	auto font = (menuMetrics == MenuMetrics::Navigation)?FontType::Body_1:FontType::Subhead;

	_menuNameLabel->setFont(font);
	_menuValueLabel->setFont(font);

	_menuNameLabel->setVisible(false);
	_menuValueLabel->setVisible(false);
	_menuNameIcon->setVisible(false);
	_menuValueIcon->setVisible(false);

	if (_source) {
		bool enabled = (_source->getCallback() != nullptr || _source->getNextMenu() != nullptr);
		float namePos = metrics::menuFirstLeftKeyline(menuMetrics);
		auto nameIcon = _source->getNameIcon();
		if (nameIcon != IconName::None) {
			_menuNameIcon->setIconName(nameIcon);
			_menuNameIcon->setPosition(cocos2d::Vec2(namePos, height / 2));
			_menuNameIcon->setVisible(true);
			_menuNameIcon->setOpacity((enabled) ? 222 : 138);

			namePos = metrics::menuSecondLeftKeyline(menuMetrics);
		} else {
			_menuNameIcon->setVisible(false);
		}

		auto name = _source->getName();
		if (!name.empty()) {
			_menuNameLabel->setString(name);
			_menuNameLabel->setPosition(cocos2d::Vec2(namePos, height / 2));
			_menuNameLabel->setVisible(true);
			_menuNameLabel->setOpacity((enabled) ? 222 : 138);
		} else {
			_menuNameLabel->setVisible(false);
		}

		if (_source->getNextMenu()) {
			_menuValueIcon->setIconName(IconName::Navigation_arrow_drop_down);
			_menuValueIcon->setPosition(cocos2d::Vec2(_contentSize.width - 8, height / 2));
			_menuValueIcon->setVisible(true);
			_menuValueIcon->setRotated(true);
		} else {
			_menuValueIcon->setVisible(false);
			_menuValueIcon->setRotated(false);
		}

		if (!_source->getValue().empty() && !_menuValueIcon->isVisible()) {
			_menuValueLabel->setVisible(true);
			_menuValueLabel->setString(_source->getValue());
			_menuValueLabel->setPosition(cocos2d::Vec2(_contentSize.width - 16, height / 2));
			_menuValueLabel->setOpacity((enabled) ? 222 : 138);
		} else {
			_menuValueLabel->setVisible(false);
		}

		if (_source->getValueIcon() != IconName::Empty && _source->getValueIcon() != IconName::None
			&& !_menuValueLabel->isVisible() && !_menuValueIcon->isVisible()) {

			_menuValueIcon->setIconName(_source->getValueIcon());
			_menuValueIcon->setPosition(cocos2d::Vec2(_contentSize.width - 16, height / 2));
			_menuValueIcon->setVisible(true);
			_menuValueIcon->setOpacity((enabled) ? 222 : 138);
		}

		if (_source->isSelected()) {
			setSelected(true, true);
		} else {
			setSelected(false);
		}

		setEnabled(enabled && _menu->isEnabled());
	}
}