Skip to content
Snippets Groups Projects
Commit f9ca900a authored by Fodor Ágoston's avatar Fodor Ágoston
Browse files

pálya betöltés kezdetlegesen

parent 7d0108d7
Branches
No related tags found
No related merge requests found
......@@ -50,10 +50,10 @@ void Application::event_loop()
if (focus != -1) {
widgets[focus]->handle(ev);
for (int k = 0; k < 81; k += 9) {
for (int i = k; i < 9+k; ++i) {
for (size_t j = i+1; j < 9+k; ++j) {
if (widgets[i]->getter() == widgets[j]->getter()) {
wrongi = j;
for (int i = k; i < 9 + k; ++i) {
for (int j = i + 1; j < 9 + k; ++j) {
if (widgets[i]->getter() != 0 && widgets[i]->getter() == widgets[j]->getter()) {
wrongi = i;
break;
}
}
......@@ -66,12 +66,11 @@ void Application::event_loop()
}
}
for (int k = 0; k < 9; ++k) {
for (int i = k; i < 81; i += 9) {
for (size_t j = i+9; j < 81; j += 9) {
if (widgets[i]->getter() == widgets[j]->getter()) {
wrongi = j;
for (int j = i + 9; j < 81; j += 9) {
if (widgets[i]->getter() != 0 && widgets[i]->getter() == widgets[j]->getter()) {
wrongi = i;
break;
}
}
......@@ -123,7 +122,7 @@ void Application::event_loop()
}
}
gout << refresh;
std::cout << widgets[11]->getter() << std::endl;
}
}
#include <iostream>
#include "application.hpp"
#include "spinbox.hpp"
#include <vector>
#include "widget.hpp"
using namespace genv;
using namespace std;
......@@ -17,23 +17,43 @@ public:
void palya()
{
vector<vector<int>> board = {
{5, 3, 0, 0, 7, 0, 0, 0, 0},
{6, 0, 0, 1, 9, 5, 0, 0, 0},
{0, 9, 8, 0, 0, 0, 0, 6, 0},
{8, 0, 0, 0, 6, 0, 0, 0, 3},
{4, 0, 0, 8, 0, 3, 0, 0, 1},
{7, 0, 0, 0, 2, 0, 0, 0, 6},
{0, 6, 0, 0, 0, 0, 2, 8, 0},
{0, 0, 0, 4, 1, 9, 0, 0, 5},
{0, 0, 0, 0, 8, 0, 0, 7, 9}
};
for (int i = 0; i < 9; ++i)
{
vector<SpinBox*> rowWidgets; // Az adott sorhoz tartozó SpinBox-ok
vector<SpinBox*> rowWidgets;
for (int j = 0; j < 9; ++j)
{
SpinBox* sp = new SpinBox(this, 5 + j * 100, 5 + i * 100, 100, 0, 9);
rowWidgets.push_back(sp); // Hozzáadjuk az új SpinBox-ot az aktuális sorhoz
SpinBox* spin;
if (board[i][j] != 0)
{
spin = new SpinBox(this, 5 + j * 100, 5 + i * 100, 100, board[i][j], board[i][j], board[i][j]);
}
else
{
spin = new SpinBox(this, 5 + j * 100, 5 + i * 100, 100, 0, 9,0);
}
rowWidgets.push_back(spin);
}
// Hozzáadjuk az aktuális sorhoz tartozó widgeteket a teljes widget listához
widgets.push_back(rowWidgets);
}
}
protected:
vector<vector<SpinBox*>> widgets; // Kétdimenziós vektor a sorok és oszlopok kezelésére
vector<vector<SpinBox*>> widgets;
};
int main()
......
......@@ -9,9 +9,9 @@ using namespace std;
int mouse_x = 0;
int mouse_y = 0;
SpinBox::SpinBox(Application* parent,int x, int y, int sizey, int min, int max) : Widget(parent,x,y,sizey*3,sizey), _min(min), _max(max), _isselected(0)
SpinBox::SpinBox(Application* parent,int x, int y, int sizey, int min, int max, int start) : Widget(parent,x,y,sizey*3,sizey), _min(min), _max(max), _num(start), _isselected(0)
{
_num = 0;
}
void SpinBox::draw()
......
......@@ -10,7 +10,7 @@ protected:
bool _isselected;
public:
SpinBox(Application* ,int, int, int,int, int);
SpinBox(Application* ,int, int, int,int, int,int);
void draw() override;
void handle(genv::event) override;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment