void Script::o_inputloopend() { debugScript(5, true, "Input loop end"); // Handle the predefined hotspots if (_hotspotTopAction) { Common::Rect rect(0, 0, 640, 80); hotspot(rect, _hotspotTopAction, _hotspotTopCursor); } if (_hotspotBottomAction) { Common::Rect rect(0, 400, 640, 480); hotspot(rect, _hotspotBottomAction, _hotspotBottomCursor); } if (_hotspotRightAction) { Common::Rect rect(560, 0, 640, 480); hotspot(rect, _hotspotRightAction, 2); } if (_hotspotLeftAction) { Common::Rect rect(0, 0, 80, 480); hotspot(rect, _hotspotLeftAction, 1); } // Actually execute the planned action if (_inputAction != -1) { // Jump to the planned address _currentInstruction = _inputAction; // Exit the input loop _inputLoopAddress = 0; _vm->_grvCursorMan->show(false); // Force immediate hiding of the mouse cursor (required when the next // video just contains audio) _vm->_graphicsMan->change(); } // Nothing to do if (_inputLoopAddress) { if (_newCursorStyle != _vm->_grvCursorMan->getStyle()) { _vm->_grvCursorMan->setStyle(_newCursorStyle); } _vm->_grvCursorMan->show(true); // Go back to the begining of the loop _currentInstruction = _inputLoopAddress; // There's nothing to do until we get some input _vm->waitForInput(); } }
virtual Q3DragObject *dragObject () { int count = 0; for ( Q3IconViewItem *it = firstItem(); it; it = it->nextItem() ) { if ( it->isSelected() ) { ++count; } } QPixmap pixmap; if ( count > 1 ) { pixmap = KIconLoader::global()->loadIcon( "mail-attachment", KIconLoader::Desktop ); } if ( pixmap.isNull() ) { pixmap = static_cast<AttachmentIconItem *>( currentItem() )->icon(); } QPoint hotspot( pixmap.width() / 2, pixmap.height() / 2 ); QDrag *drag = new QDrag( this ); drag->setMimeData( mimeData() ); drag->setPixmap( pixmap ); drag->setHotSpot( hotspot ); drag->exec( Qt::CopyAction ); return 0; }
adobe_cursor_t make_cursor(const char* cursor_path, float hot_spot_x, float hot_spot_y) { if (!g_default_cursor) g_default_cursor = GG::GUI::GetGUI()->GetCursor(); boost::shared_ptr<GG::Texture> texture = GG::GUI::GetGUI()->GetTexture(cursor_path); GG::Pt hotspot(GG::X(hot_spot_x + 0.5), GG::Y(hot_spot_y + 0.5)); return adobe_cursor_t(new GG::TextureCursor(texture, hotspot)); }
void Script::o_hotspot_center() { uint16 address = readScript16bits(); debugScript(5, true, "HOTSPOT-CENTER @0x%04X", address); // Mark the centremost 240 pixels of the game area Common::Rect rect(200, 80, 440, 400); hotspot(rect, address, 0); }
void Script::o_hotspot_right() { uint16 address = readScript16bits(); debugScript(5, true, "HOTSPOT-RIGHT @0x%04X", address); // Mark the rightmost 100 pixels of the game area Common::Rect rect(540, 80, 640, 400); hotspot(rect, address, 2); }
void Script::o_hotspot_left() { uint16 address = readScript16bits(); debugScript(5, true, "HOTSPOT-LEFT @0x%04X", address); // Mark the leftmost 100 pixels of the game area Common::Rect rect(0, 80, 100, 400); hotspot(rect, address, 1); }
void Script::o_hotspotbottom_4() { //0x30 uint16 address = readScript16bits(); debugScript(5, true, "HOTSPOT-BOTTOM @0x%04X", address); // Mark the 80 pixels under the game area Common::Rect rect(0, 400, 640, 480); hotspot(rect, address, 4); }
void Script::o_hotspot_current() { uint16 address = readScript16bits(); debugScript(5, true, "HOTSPOT-CURRENT @0x%04X", address); // The original interpreter doesn't check the position, so accept the // whole screen Common::Rect rect(0, 0, 640, 480); hotspot(rect, address, 0); }
// Refresh the style. void QsciStyle::refresh() { setColor(color()); setPaper(paper()); setFont(font()); setEolFill(eolFill()); setTextCase(textCase()); setVisible(visible()); setChangeable(changeable()); setHotspot(hotspot()); }
void Script::o_hotspot_rect() { uint16 left = readScript16bits(); uint16 top = readScript16bits(); uint16 right = readScript16bits(); uint16 bottom = readScript16bits(); uint16 address = readScript16bits(); uint8 cursor = readScript8bits(); debugScript(5, true, "HOTSPOT-RECT(%d,%d,%d,%d) @0x%04X cursor=%d", left, top, right, bottom, address, cursor); // Mark the specified rectangle Common::Rect rect(left, top, right, bottom); hotspot(rect, address, cursor); }
void Script::o_hotspot_slot() { uint16 slot = readScript8bits(); uint16 left = readScript16bits(); uint16 top = readScript16bits(); uint16 right = readScript16bits(); uint16 bottom = readScript16bits(); uint16 address = readScript16bits(); uint16 cursor = readScript8bits(); debugScript(1, true, "HOTSPOT-SLOT %d (%d,%d,%d,%d) @0x%04X cursor=%d (TODO)", slot, left, top, right, bottom, address, cursor); Common::Rect rect(left, top, right, bottom); if (hotspot(rect, address, cursor)) { if (_hotspotSlot == slot) { return; } Common::Rect topbar(640, 80); Graphics::Surface *gamescreen = _vm->_system->lockScreen(); // Clear the top bar gamescreen->fillRect(topbar, 0); printString(gamescreen, _saveNames[slot].c_str()); _vm->_system->unlockScreen(); // Save the currently highlighted slot _hotspotSlot = slot; } else { if (_hotspotSlot == slot) { Common::Rect topbar(640, 80); Graphics::Surface *gamescreen; gamescreen = _vm->_system->lockScreen(); gamescreen->fillRect(topbar, 0); _vm->_system->unlockScreen(); // Removing the slot highlight _hotspotSlot = (uint16)-1; } } }
// The start of the Application int App::start(const std::vector<CL_String> &args) { quit = false; try { CL_OpenGLWindowDescription desc; desc.set_title("ClanLib AnimCursor Test"); desc.set_size(CL_Size(800, 600), true); CL_DisplayWindow window(desc); // Connect the Window close event CL_Slot slot_quit = window.sig_window_close().connect(this, &App::on_window_close); // Connect a keyboard handler to on_key_up() CL_Slot slot_input_up = (window.get_ic().get_keyboard()).sig_key_up().connect(this, &App::on_input_up); // Get the graphic context CL_GraphicContext gc = window.get_gc(); CL_Font font = CL_Font(gc, "Tahoma", 20); CL_PixelBuffer pacman("pacman.png"); CL_SpriteDescription description; CL_Size size(22, 22); for (int frame_cnt=0; frame_cnt < 6; frame_cnt++) { CL_PixelBuffer frame(size.width, size.height, cl_rgba8); pacman.convert(frame, size, CL_Rect((frame_cnt * 28) + 4, 4, size)); description.add_frame(frame); description.set_frame_delay(frame_cnt, 0.1); } CL_Point hotspot(0,0); CL_Cursor cursor(window, description, hotspot); window.set_cursor(cursor); // Run until someone presses escape while (!quit) { gc.clear(CL_Colorf(0.0f,0.0f,0.5f)); font.draw_text(gc, 32, 32, "Observe the animated cursor"); // Flip the display, showing on the screen what we have drawed // since last call to flip() window.flip(1); // This call processes user input and other events CL_KeepAlive::process(); } } catch(CL_Exception& exception) { // Create a console window for text-output if not available CL_ConsoleWindow console("Console", 80, 200); CL_Console::write_line("Exception caught:"); CL_Console::write_line(exception.message); // Display the stack trace (if available) std::vector<CL_String> stacktrace = exception.get_stack_trace(); int size = stacktrace.size(); if (size > 0) { CL_Console::write_line("Stack Trace:"); for (int cnt=0; cnt < size; cnt++) { CL_Console::write_line(stacktrace[cnt]); } } console.display_close_message(); return -1; } return 0; }
int setup_wlaninterface(struct config_interfaces * target) { int retries = 1, res = 0; struct config_ssid *match, *all = all_matching_network(target); char *if_name = target->if_name; match = all; if (!match) return 0; if (network_matches(if_name, match)) { printf("already using matched ssid, we do nothing\n"); clear_ssid(all); return 1; } while (match) { printf("setting up network: %s\n", match->ssid_name); set_network_id((char *) match->ssid_name, if_name); printf("%s\n", match->ssid_auth); update_status(CONNECTING, match->ssid_name); if (strcmp(match->ssid_auth, "802.1x") == 0) { printf("do 8021x stuff\n"); if (!target->supplicant_pid) target->supplicant_pid = start_wpa_supplicant(target->if_name, target->supplicant_pid, 1); cleanup_interface(target, 8); set_bssid((char *) match->ssid_bssid, if_name, 1); set_wpa8021x(if_name, 1); sleep(3); config_wpa_supplicant(if_name, match, 1); } else if (strcmp(match->ssid_auth, "wpa") == 0) { printf("do wpa stuff\n"); cleanup_interface(target, 4); set_psk_key((char *) match->ssid_name, (char *) match->ssid_pass, if_name, 1); } else if (strcmp(match->ssid_auth, "wep") == 0) { printf("do wep stuff\n"); cleanup_interface(target, 2); set_wep_key((char *) match->ssid_pass, if_name, 1); } else if (strcmp(match->ssid_auth, "none") == 0) { printf("no security has been set\n"); cleanup_interface(target, 1); } if (target->ipv6_auto) set_ipv6_auto(if_name); start_dhclient(if_name); while (retries != 0) { if (connection_active(if_name, 1)) { /* * If we are successfully connected to the network * and we don't need additional auth, then we are good. */ sleep(1); res = internet_connectivity_check(match); if (res == 1) { update_status(CONNECTED, match->ssid_name); return 1; } else if (res == 2) { /* * This is a hotspot; run user-defined command * or open default web browser. */ if (!config->additional_auth_exec) hotspot(match); return 1; } else { printf("not active, waiting...\n"); sleep(5); retries--; } } } match = match->next; retries = 1; } clear_ssid(all); return res; }
int network_matches(char *if_name, struct config_ssid * match) { struct ifreq ifr; struct ieee80211_nwid nwid; struct ieee80211_bssid bssid; char current_bssid[20]; int s = -1, res, ires; s = open_socket(AF_INET); if (s < 0) { printf("error opening socket: %s\n", strerror(errno)); return 0; } memset(&ifr, 0, sizeof(ifr)); ifr.ifr_data = (caddr_t) & nwid; strlcpy(ifr.ifr_name, if_name, sizeof(ifr.ifr_name)); res = ioctl(s, SIOCG80211NWID, (caddr_t) & ifr); printf("current nwid on interface: %s\n", nwid.i_nwid); if (res) printf("res: %d (%s)\n", res, strerror(errno)); /* * First of all, check if the SSID of the match found is the same as * the one the interface is using. */ if (strcmp((const char *) nwid.i_nwid, match->ssid_name) == 0) { printf("passed nwid string cmp\n"); /* * If it is, check if the BSSID is the same as the one the * interface is using (if they are the same access point). * Return true if they are the same AP. */ struct ether_addr ea; memset(&bssid, 0, sizeof(bssid)); strlcpy(bssid.i_name, if_name, sizeof(bssid.i_name)); res = ioctl(s, SIOCG80211BSSID, &bssid); if (res) printf("res: %d (%s)\n", res, strerror(errno)); memcpy(&ea.ether_addr_octet, bssid.i_bssid, sizeof(ea.ether_addr_octet)); /* Convert BSSID from binary to ASCII */ strlcpy(current_bssid, ether_ntoa(&ea), sizeof(current_bssid)); if (strcmp(current_bssid, match->ssid_bssid) == 0) { printf("passed bssid string cmp\n"); close(s); /* * The one we want is already on the interface. * Now check if it's connected to the wlan, if it's not * then we need to try dhclient again. */ if (connection_active(if_name, 1)) { /* * If we are successfully connected to the network * and we don't need additional auth, then we are good. */ ires = internet_connectivity_check(match); if (ires == 1) return 1; else if (ires == 2) { /* * This is a hotspot; run * user-defined command or open * default web browser. */ if (!config->additional_auth_exec) hotspot(match); return 1; } else /* Try dhclient again. */ return 0; } else { printf("connection not active; trying dhclient again\n"); return 0; } } } /* Do all the signal checking stuff. */ struct ieee80211_nodereq nr; memset(&nr, 0, sizeof(nr)); memcpy(&nr.nr_macaddr, bssid.i_bssid, sizeof(nr.nr_macaddr)); strlcpy(nr.nr_ifname, if_name, sizeof(nr.nr_ifname)); res = ioctl(s, SIOCG80211NODE, (caddr_t) & nr); int8_t new_rssi; int8_t old_rssi; if (res) printf("res: %d (%s)\n", res, strerror(errno)); close(s); printf("rssi is: %d\n", nr.nr_rssi); /* No network to compare with; connect to new network. */ if (res == -1) return 0; /* * Different chipsets measure RSSI values differently need to * accommodate when 0 is minimum value and when 0 is maximum value. */ if (nr.nr_max_rssi) { new_rssi = match->ssid_rssi; old_rssi = nr.nr_rssi; } else { new_rssi = match->ssid_rssi + 100; old_rssi = nr.nr_rssi + 100; } /* * Switch over if new network is higher RSSI value than (old*1.5). */ if (new_rssi > (old_rssi * 1.5)) { printf("switching over to new network\n"); return 0; } else { printf("staying on old network\n"); return 1; } }
void TestApp::test_vector2(void) { Console::write_line(" Header: cl_vector.h"); Console::write_line(" Class: Vec2"); Console::write_line(" Function: rotate()"); { Vec2i test_a; Vec2i hotspot(1,3); test_a = Vec2i(4,5); test_a.rotate(hotspot, Angle(0, angle_degrees)); if (test_a != Vec2i(4, 5)) fail(); test_a = Vec2i(4,5); test_a.rotate(hotspot, Angle(90, angle_degrees)); if (test_a != Vec2i(-1, 6)) fail(); test_a = Vec2i(4,5); test_a.rotate(hotspot, Angle(180, angle_degrees)); if (test_a != Vec2i(-2, 1)) fail(); test_a = Vec2i(4,5); test_a.rotate(hotspot, Angle(270, angle_degrees)); if (test_a != Vec2i(3, 0)) fail(); test_a = Vec2i(4,5); test_a.rotate(hotspot, Angle(360, angle_degrees)); if (test_a != Vec2i(4, 5)) fail(); test_a = Vec2i(4,5); test_a.rotate(Vec2i(0,0), Angle(180, angle_degrees)); if (test_a != Vec2i(-4, -5)) fail(); } Console::write_line(" Function: distance()"); { Vec2d test_a(2.0,3.0); Vec2d test_b(3.0,4.0); if (test_a.distance(test_b) != sqrt(1.0 + 1.0 )) fail(); } Console::write_line(" Function: normalize()"); { Vec2d testi(3.0,4.0); testi.normalize(); if (testi != Vec2d(3.0/sqrt(25.0), 4.0/sqrt(25.0))) fail(); } Console::write_line(" Function: static normalize()"); { Vec2d testi(3.0,4.0); if (Vec2d::normalize(testi) != Vec2d(3.0/sqrt(25.0), 4.0/sqrt(25.0))) fail(); } Console::write_line(" Function: length()"); { Vec2d testi(3.0,4.0); if (testi.length() != sqrt(25.0 )) fail(); } Console::write_line(" Function: dot()"); { Vec2d test_a(3.0,4.0); Vec2d test_b(13.0,14.0); if (test_a.dot(test_b) != ((3.0 * 13.0)+ (4.0*14.0))) fail(); } Console::write_line(" Function: operator += (const Vec2<Type>& vector)"); { Vec2d testd(2.5, 3.5); testd += Vec2d(1.0, 2.0); if (testd.x != 3.5) fail(); if (testd.y != 5.5) fail(); Vec2i testi(2, 3); testi += Vec2i(1, 2); if (testi.x != 3) fail(); if (testi.y != 5) fail(); } Console::write_line(" Function: operator += ( Type value)"); { Vec2d testd(2.5, 3.5); double valued = 2.0; testd += valued; if (testd.x != 4.5) fail(); if (testd.y != 5.5) fail(); Vec2i testi(2, 3); int valuei = 2; testi += valuei; if (testi.x != 4) fail(); if (testi.y != 5) fail(); } Console::write_line(" Function: operator + (Type value)"); { Vec2d testd(2.5, 3.5); double valued = 2.0; testd = testd + valued; if (testd.x != 4.5) fail(); if (testd.y != 5.5) fail(); Vec2i testi(2, 3); int valuei = 2; testi = testi + valuei; if (testi.x != 4) fail(); if (testi.y != 5) fail(); } Console::write_line(" Function: operator + (const Vec2<Type>& vector)"); { Vec2d testd(2.5, 3.5); testd = testd + Vec2d(1.5, 2.5); if (testd.x != 4.0) fail(); if (testd.y != 6.0) fail(); Vec2i testi(2, 3); testi = testi + Vec2i(1, 2); if (testi.x != 3) fail(); if (testi.y != 5) fail(); } Console::write_line(" Function: operator -= (const Vec2<Type>& vector)"); { Vec2d testd(2.5, 3.5); testd -= Vec2d(1.0, 2.0); if (testd.x != 1.5) fail(); if (testd.y != 1.5) fail(); Vec2i testi(2, 3); testi -= Vec2i(1, 2); if (testi.x != 1) fail(); if (testi.y != 1) fail(); } Console::write_line(" Function: operator -= ( Type value)"); { Vec2d testd(2.5, 3.5); double valued = 2.0; testd -= valued; if (testd.x != 0.5) fail(); if (testd.y != 1.5) fail(); Vec2i testi(2, 3); int valuei = 2; testi -= valuei; if (testi.x != 0) fail(); if (testi.y != 1) fail(); } Console::write_line(" Function: operator - (Type value)"); { Vec2d testd(2.5, 3.5); double valued = 2.0; testd = testd - valued; if (testd.x != 0.5) fail(); if (testd.y != 1.5) fail(); Vec2i testi(2, 3); int valuei = 2; testi = testi - valuei; if (testi.x != 0) fail(); if (testi.y != 1) fail(); } Console::write_line(" Function: operator - (const Vec2<Type>& vector)"); { Vec2d testd(2.5, 3.5); testd = testd - Vec2d(1.5, 2.5); if (testd.x != 1.0) fail(); if (testd.y != 1.0) fail(); Vec2i testi(2, 3); testi = testi - Vec2i(1, 2); if (testi.x != 1) fail(); if (testi.y != 1) fail(); } Console::write_line(" Function: operator *= (const Vec2<Type>& vector)"); { Vec2d testd(2.5, 3.5); testd *= Vec2d(1.0, 2.0); if (testd.x != 2.5) fail(); if (testd.y != 7.0) fail(); Vec2i testi(2, 3); testi *= Vec2i(1, 2); if (testi.x != 2) fail(); if (testi.y != 6) fail(); } Console::write_line(" Function: operator *= ( Type value)"); { Vec2d testd(2.5, 3.5); double valued = 2.0; testd *= valued; if (testd.x != 5.0) fail(); if (testd.y != 7.0) fail(); Vec2i testi(2, 3); int valuei = 2; testi *= valuei; if (testi.x != 4) fail(); if (testi.y != 6) fail(); } Console::write_line(" Function: operator * (Type value)"); { Vec2d testd(2.5, 3.5); double valued = 2.0; testd = testd * valued; if (testd.x != 5.0) fail(); if (testd.y != 7.0) fail(); Vec2i testi(2, 3); int valuei = 2; testi = testi * valuei; if (testi.x != 4) fail(); if (testi.y != 6) fail(); } Console::write_line(" Function: operator * (const Vec2<Type>& vector)"); { Vec2d testd(2.5, 3.5); testd = testd * Vec2d(1.5, 2.5); if (testd.x != 3.75) fail(); if (testd.y != 8.75) fail(); Vec2i testi(2, 3); testi = testi * Vec2i(1, 2); if (testi.x != 2) fail(); if (testi.y != 6) fail(); } Console::write_line(" Function: operator /= (const Vec2<Type>& vector)"); { Vec2d testd(2.5, 3.5); testd /= Vec2d(1.0, 2.0); if (testd.x != 2.5) fail(); if (testd.y != 1.75) fail(); Vec2i testi(2, 10); testi /= Vec2i(1, 2); if (testi.x != 2) fail(); if (testi.y != 5) fail(); } Console::write_line(" Function: operator /= ( Type value)"); { Vec2d testd(2.5, 3.5); double valued = 2.0; testd /= valued; if (testd.x != 1.25) fail(); if (testd.y != 1.75) fail(); Vec2i testi(2, 10); int valuei = 2; testi /= valuei; if (testi.x != 1) fail(); if (testi.y != 5) fail(); } Console::write_line(" Function: operator / (Type value)"); { Vec2d testd(2.5, 3.5); double valued = 2.0; testd = testd / valued; if (testd.x != 1.25) fail(); if (testd.y != 1.75) fail(); Vec2i testi(2, 10); int valuei = 2; testi = testi / valuei; if (testi.x != 1) fail(); if (testi.y != 5) fail(); } Console::write_line(" Function: operator / (const Vec2<Type>& vector)"); { Vec2d testd(2.5, 3.5); testd = testd / Vec2d(1.0, 2.5); if (testd.x != 2.5) fail(); if (testd.y != 1.4) fail(); Vec2i testi(2, 10); testi = testi / Vec2i(1, 2); if (testi.x != 2) fail(); if (testi.y != 5) fail(); } Console::write_line(" Function: operator = (const Vec2<Type>& vector)"); { Vec2d testd(2.5, 3.5); testd = Vec2d(1.0, 2.0); if (testd.x != 1.0) fail(); if (testd.y != 2.0) fail(); Vec2i testi(2, 3); testi = Vec2i(1, 2); if (testi.x != 1) fail(); if (testi.y != 2) fail(); } Console::write_line(" Function: operator == (const Vec2<Type>& vector)"); { Vec2d testd(2.5, 3.5); if (testd == Vec2d(1.0, 2.0)) fail(); if (testd == Vec2d(2.5, 2.0)) fail(); if (!(testd == Vec2d(2.5, 3.5))) fail(); Vec2i testi(2, 3); if (testi == Vec2i(1, 2)) fail(); if (testi == Vec2i(2, 2)) fail(); if (!(testi == Vec2i(2, 3))) fail(); } Console::write_line(" Function: operator != (const Vec2<Type>& vector)"); { Vec2d testd(2.5, 3.5); if (!(testd != Vec2d(1.0, 2.0))) fail(); if (!(testd != Vec2d(2.5, 2.0))) fail(); if ((testd != Vec2d(2.5, 3.5))) fail(); Vec2i testi(2, 3); if (!(testi != Vec2i(1, 2))) fail(); if (!(testi != Vec2i(2, 2))) fail(); if ((testi != Vec2i(2, 3))) fail(); } Console::write_line(" Function: round()"); { Vec2d testd(2.0, 2.5); testd.round(); if (testd.x != 2.0) fail(); if (testd.y != 3.0) fail(); Vec2f testf(2.0f, 2.5f); testf.round(); if (testf.x != 2.0f) fail(); if (testf.y != 3.0f) fail(); } Console::write_line(" Function: static round()"); { Vec2d testd(2.0, 2.5); Vec2d destd = Vec2d::round(testd); if (destd.x != 2.0) fail(); if (destd.y != 3.0) fail(); Vec2f testf(2.0f, 2.5f); Vec2f destf = Vec2f::round(testf); if (destf.x != 2.0f) fail(); if (destf.y != 3.0f) fail(); } }
void DragIcon::useForDrag(GdkDragContext* context) { IntPoint hotspot(m_imageSize); hotspot.scale(0.5, 0.5); useForDrag(context, hotspot); }