Exemple #1
0
/* ============================================================================
* Funktion:        createTableHead
* Input:           int width  Fensterbreite in Cols
* Output:          -
*
* Beschreibung:    Gibt den Tabellenkopf aus
* =============================================================================
*/
void createTableHead(int width)
{
   char borderTopSide[2], borderTopRight[2], borderTopLeft[2], borderSide[2];
   char borderTopBot[2], borderLeftSide[2], borderRightSide[2], borderCross[2];
   int i=0;

   sprintf(borderTopSide, "%c", 203);
   sprintf(borderTopRight, "%c", 187);
   sprintf(borderTopLeft, "%c", 201);
   sprintf(borderSide, "%c", 186);
   sprintf(borderTopBot, "%c", 205);
   sprintf(borderLeftSide, "%c", 204);
   sprintf(borderRightSide, "%c", 185);
   sprintf(borderCross, "%c", 206);

   /* top border */
   for(i=0;i<80;i++)
   {
      if(i==20||i==40||i==60)
      {
         printTo(((width) / 2)-40+i, 4, borderTopSide, 0 );
      }
      else
      {
         printTo(((width) / 2)-40+i, 4, borderTopBot, 0 );
      }
   }
   printTo(((width)/ 2)-40, 4, borderTopLeft, 0);
   printTo(((width)/ 2)+40, 4, borderTopRight, 0);
   createTableRow("Rank", "Username", "Score", "Time", 5, width);
   createRowSplitter(width, 6);
}
Exemple #2
0
/* ============================================================================
* Funktion:        toplist
* Input:           -
* Output:          -
*
* Beschreibung:    Holt die Topliste aus der Datenbank und gibt sie aus.
* =============================================================================
*/
void toplist(ACCOUNT user)
{
   int num_fields = 0, iStatus = 0, iTemp = 1, iLength = 0, i = 0, m_Exit = 0;
   int x = 0, xpos=0, ypos=0, page=1, j[3];
   char *cMenu[SUDOKU_DIFFICULTIES] = {
                               "Easy",
                               "Medium",
                               "Hard",
                               "Exit"
                            };
   char userList[SUDOKU_DIFFICULTIES][100][3][100];
   char highLight[2], cQuery[300], cString[200], coods[20], number[10];
   MYSQL_ROW ROW;
   MYSQL_RES *topList[3] = {NULL, NULL, NULL};
   MYSQL *Connection = NULL;

   sprintf(highLight, "%c", 16);
   system("cls");

	createBlockView(WINDOW_WIDTH, 37);
	createBlockView(WINDOW_WIDTH, 10);

   printTo(((WINDOW_WIDTH-13)/2), 40, "T O P L I S T", 0);
   printTo(((WINDOW_WIDTH-13)/2), 41, "= = = = = = =", 0);
   for (i = 0; i < SUDOKU_DIFFICULTIES; i++)
   {
      printTo(((WINDOW_WIDTH-13)/2), 43+ i, cMenu[i], 0);
   }
   printTo(((WINDOW_WIDTH-13)/2)-5, 43, highLight, 0 );

   Connection = MySQLConnect();
   x=0;
   for(i=0; i<SUDOKU_DIFFICULTIES; i++)
   {
      x=0;
      sprintf(cQuery,
         "SELECT a.username, p.points, p.time FROM accounts a JOIN points p ON (a.id = p.userid) WHERE difficulty = %i ORDER BY p.points DESC, p.time ASC LIMIT 10",
          i+1 );
      topList[i] = QueryBuilder(Connection, cQuery);
      if(topList[i])
      {
         while (ROW = mysql_fetch_row(topList[i]))
         {
            strcpy(userList[i][x][0], ROW[0]);
            strcpy(userList[i][x][1], ROW[1]);
            strcpy(userList[i][x][2], ROW[2]);
            x++;
         }
      }
      j[i] = x;
      mysql_free_result(topList[i]);
   }
   MySQLClose(Connection);
	
   renderToplist(WINDOW_WIDTH);
   createTableHead(WINDOW_WIDTH);
   
	if(j[iTemp-1] > 10 )
   {
      iLength = (page*10);
   }
   else
   {
      iLength = j[iTemp-1];
   }
	
   for(i=0; i<iLength;i++)
   {
      _itoa(i+1,number,10);
		createTableRow(number, userList[iTemp-1][i][0], userList[iTemp-1][i][1],
                     userList[iTemp-1][i][2], (i*2)+5+2, WINDOW_WIDTH);
   }
   closingRow((i*2)+6, WINDOW_WIDTH);
   gotoxy(WINDOW_WIDTH - 1, 0);
   do
   {
      do
      {
         iStatus = control();
         printTo(((WINDOW_WIDTH-13)/2)-5, 42+ iTemp, " ", 0);

         if (iStatus == 2)
         {
            if (iTemp > 1)
            {
               iTemp--;
            }
         }
         else if (iStatus == 3)
         {
            if (iTemp < SUDOKU_DIFFICULTIES && iTemp > 0)
            {
               iTemp++;
            }
         }
         xpos = ((WINDOW_WIDTH - 13) / 2) - 5;
         ypos = ((WINDOW_HEIGHT / 3) * 2) + iTemp;
         sprintf(coods,"");
         printTo(((WINDOW_WIDTH-13)/2)-5, 42+ iTemp, highLight, 0);
         gotoxy(WINDOW_WIDTH - 1, 0);
      } while (iStatus != 6);

      switch (iTemp)
      {
         case 1:
         case 2:
         case 3:
            renderToplist(WINDOW_WIDTH);
            if(j[iTemp-1]>10)
            {
               iLength = (page*10);
            }
            else
            {
               iLength = j[iTemp-1];
            }

            createTableHead(WINDOW_WIDTH);

            for(i=0; i<iLength; i++)
            {
               _itoa(i+1,number,10);
					createTableRow(number, userList[iTemp-1][i][0], userList[iTemp-1][i][1],
									userList[iTemp-1][i][2], (i*2)+5+2, WINDOW_WIDTH);
            }
            closingRow((i*2)+6, WINDOW_WIDTH);
            gotoxy(WINDOW_WIDTH - 1, 0);
         break;
         case 4:
            m_Exit = 1;
         break;
      }
   } while (!m_Exit);
}
Exemple #3
0
int main(int argc, char** argv) {
    osgViewer::Viewer viewer;

    osgWidget::WindowManager* wm = new osgWidget::WindowManager(
        &viewer,
        1280.0f,
        1024.0f,
        MASK_2D,
        osgWidget::WindowManager::WM_PICK_DEBUG
    );
    
    osgWidget::Box*   box   = new osgWidget::Box("vbox", osgWidget::Box::VERTICAL);
    osgWidget::Table* table = new osgWidget::Table("table", 3, 2);
    osgWidget::Box*   lbox1 = new osgWidget::Box("lbox1", osgWidget::Box::HORIZONTAL);
    osgWidget::Box*   lbox2 = new osgWidget::Box("lbox2", osgWidget::Box::HORIZONTAL);
    osgWidget::Frame* frame = osgWidget::Frame::createSimpleFrameWithSingleTexture(
        "frame",
        "osgWidget/theme.png",
        64.0f,
        64.0f,
        16.0f,
        16.0f,
        100.0f,
        100.0f
    );

    osgWidget::Input* x = createTableRow(table, 0, "X Position");
    osgWidget::Input* y = createTableRow(table, 1, "Y Position");
    osgWidget::Input* z = createTableRow(table, 2, "Z Position");
    
    Button::Inputs inputs;

    inputs.push_back(x);
    inputs.push_back(y);
    inputs.push_back(z);

    table->addCallback(osgWidget::Callback(&info, osgWidget::EVENT_MOUSE_PUSH));

    lbox1->addWidget(createLabel(INFO));
    lbox2->addWidget(new Button("Add To Scene...", inputs));

    box->addWidget(lbox1->embed());
    box->addWidget(table->embed());
    box->addWidget(lbox2->embed());
    box->addCallback(osgWidget::Callback(&info, osgWidget::EVENT_MOUSE_PUSH));

    frame->setWindow(box);
    frame->getEmbeddedWindow()->setSize(box->getWidth(), box->getHeight());
    frame->getBackground()->setColor(0.0f, 0.0f, 0.0f, 0.0f);
    frame->attachTabFocusCallback();

    for(osgWidget::Frame::Iterator i = frame->begin(); i != frame->end(); i++) {
        if(i->valid()) i->get()->setColor(0.5f, 0.7f, 1.0f, 1.0f);
    }

    wm->addChild(frame);

    /*
    // Print out our focus list, it should just have 3 widgets.
    osgWidget::WidgetList wl;

    box->getFocusList(wl);

    for(osgWidget::WidgetList::iterator i = wl.begin(); i != wl.end(); i++) {
        osgWidget::warn() << i->get()->getName() << std::endl;
    }
    */
    
    lbox1->getBackground()->setColor(1.0f, 0.0f, 0.0f, 1.0f, osgWidget::Widget::UPPER_LEFT);
    lbox1->getBackground()->setColor(0.0f, 1.0f, 0.0f, 1.0f, osgWidget::Widget::LOWER_LEFT);
    lbox1->getBackground()->setColor(0.0f, 0.0f, 1.0f, 1.0f, osgWidget::Widget::LOWER_RIGHT);
    lbox1->getBackground()->setColor(1.0f, 1.0f, 1.0f, 1.0f, osgWidget::Widget::UPPER_RIGHT);
    lbox1->setVisibilityMode(osgWidget::Window::VM_ENTIRE);
    lbox1->update();

    int r = osgWidget::createExample(viewer, wm);

    // osgWidget::writeWindowManagerNode(wm);
    // osgDB::writeNodeFile(*box, "osgWidget.osg");

    return r;
}